示例#1
0
VALUE create_amq_wire_api_cls() {
  VALUE rb_wapi;
  amq_wire_api_cls *obj=ALLOC(amq_wire_api_cls);
  //  obj->field_list=field_list;    
  rb_wapi = Data_Wrap_Struct(rb_wireapi,0,free_amq_wire_api_cls,obj);  
  if (wire_api_ref_counter==0) {
	icl_system_initialise (0,0);
  }
  ++wire_api_ref_counter;
  obj->instance_id=++wire_api_instance_counter;
  return rb_wapi;
}
示例#2
0
文件: tstnull.c 项目: cookrn/openamq
int
main (int argc, char *argv [])
{
    icl_console_mode (ICL_CONSOLE_DATE, FALSE);
    icl_console_mode (ICL_CONSOLE_TIME, FALSE);
    icl_console_mode (ICL_CONSOLE_THREAD, TRUE);

    icl_system_initialise (argc, argv);
    smt_initialise ();
    tstnull_init ();
    smt_wait (0);
    icl_system_terminate ();
    return (0);
}
示例#3
0
int main (int argc, char *argv [])
{
    int
        count;
        
    icl_system_initialise (argc, argv);
    icl_console_mode (ICL_CONSOLE_THREAD, TRUE);
    if (argc != 3) {
        icl_console_print ("Syntax: smt_demo_client <string1> <string2>");
        return (1);
    }
    smt_initialise ();
    smt_demo_server_init ();
    for (count = 0; count < 1; count++) {
        smt_demo_client_init (argv [1], argv [2]);
    }
    smt_wait (0);
    
    icl_system_terminate ();
    return (0);
}
示例#4
0
        inline openamq_t (const char *host_, const char *send_rk_,
            const char *receive_rk_, bool direct)
        {
	    //  Store routing keys.
            strncpy (send_rk, send_rk_, 256);
	    strncpy (receive_rk, receive_rk_, 256);

            //  Initialise iCL.
            icl_system_initialise (0, NULL);

            //  Open a connection.
            icl_longstr_t *auth_data =
                amq_client_connection_auth_plain ("guest", "guest");
            connection = amq_client_connection_new (
                (char*) host_, "/", auth_data, "perf", 0, 30000);
            assert (connection);
            icl_longstr_destroy (&auth_data);

            //  Switch into direct mode if required.
            if (direct)
                connection->direct = TRUE;

            //  Open a channel.
            session = amq_client_session_new (connection);
            assert (session);

           //  Create a private queue.
           amq_client_session_queue_declare (
               session, 0, NULL, FALSE, FALSE, TRUE, TRUE, NULL);

           //  Bind the queue to the exchange.
           amq_client_session_queue_bind (session, 0, NULL, "amq.direct",
               (char*) receive_rk, NULL);

           //  Consume from the queue.
           amq_client_session_basic_consume (
               session, 0, NULL, NULL, TRUE, TRUE, TRUE, NULL);
        }
示例#5
0
int main (int argc, char *argv[])
{
    int
        argn;                           //  Argument number
    Bool
        args_ok = TRUE,                 //  Were the arguments okay?
        quiet_mode = FALSE;             //  -q means suppress messages
    char
        **argparm;                      //  Argument parameter to pick-up

    argparm = NULL;                     //  Argument parameter to pick-up
    for (argn = 1; argn < argc; argn++) {
        //  If argparm is set, we have to collect an argument parameter
        if (argparm) {
            if (*argv [argn] != '-') {  //  Parameter can't start with '-'
                *argparm = argv [argn];
                argparm = NULL;
            }
            else {
                args_ok = FALSE;
                break;
            }
        }
        else
        if (*argv [argn] == '-') {
            switch (argv [argn][1]) {
                case 'q':
                    quiet_mode = TRUE;
                    break;
                case 'v':
                    printf (PRODUCT "\n");
                    printf (COPYRIGHT "\n");
                    printf (BUILDMODEL "\n");
                    printf ("Built on: " BUILDDATE "\n");
                    printf ("Compiler: " CCOPTS "\n");
                    exit (EXIT_SUCCESS);
                case 'h':
                    printf (PRODUCT "\n");
                    printf (COPYRIGHT "\n");
                    printf ("Options:\n");
                    printf ("  -q  - Quiet mode: no messages\n");
                    printf ("  -v  - Show version information\n");
                    printf ("  -h  - Show summary of command-line options\n");
                    exit (EXIT_SUCCESS);
                //  Anything else is an error
                default:
                    args_ok = FALSE;
            }
        }
        else {
            args_ok = FALSE;
            break;
        }
    }

    //  Set quiet console mode before initialise so we don't get memory
    //  allocator message in quiet mode.
    if (quiet_mode)
        icl_console_mode (ICL_CONSOLE_QUIET, TRUE);

    //  Initialise global class so we can use the console
    icl_system_initialise (argc, argv);

    //  If there was a missing parameter or an argument error, quit
    if (argparm) {
        icl_console_print ("E: argument missing - use '-h' option for help");
        exit (EXIT_FAILURE);
    }
    else
    if (!args_ok) {
        icl_console_print ("E: invalid arguments - use '-h' option for help");
        exit (EXIT_FAILURE);
    }

    http_server_selftest ();

    icl_console_print ("I: http_server OK");
    icl_system_terminate ();            //  Terminate all classes

    return (EXIT_SUCCESS);
}
示例#6
0
int main (int argc, char *argv[])
{
    int
        argn;                           //  Argument number
    Bool
        args_ok = TRUE,                 //  Were the arguments okay?
        s_opt_broker = FALSE,           //  -b means show broker status
        s_opt_clients = FALSE,          //  -c means show clients
        s_opt_report = FALSE,           //  -r means report brokers
        s_opt_addr = FALSE,             //  -a means show addresses
        s_opt_date = FALSE;             //  -d means show date, time
    char
        *s_opt_host = NULL,             //  -s specifies server name
        *s_opt_user = NULL,             //  -u specifies user name
        *s_opt_pass = NULL,             //  -p specifies password
        *s_opt_vhost = NULL,            //  -V specifies virtual host
        *s_opt_command = NULL,          //  -e specifies command string
        *s_opt_trace = NULL,            //  -t specifies trace level
        *s_opt_xml  = NULL;             //  -x specifies XML filename
    char
        **argparm;                      //  Argument parameter to pick-up
    amq_mgt_console_t
        *console;
    ipr_token_list_t
        *tokens;                        //  Command tokens
    FILE
        *xml_data = NULL;               //  XML capture stream

    argparm = NULL;                     //  Argument parameter to pick-up
    for (argn = 1; argn < argc; argn++) {
        //  If argparm is set, we have to collect an argument parameter
        if (argparm) {
            if (*argv [argn] != '-') {  //  Parameter can't start with '-'
                *argparm = argv [argn];
                argparm = NULL;
            }
            else {
                args_ok = FALSE;
                break;
            }
        }
        else
        if (*argv [argn] == '-') {
            switch (argv [argn][1]) {
                case 's':
                    argparm = &s_opt_host;
                    break;
                case 'u':
                    argparm = &s_opt_user;
                    break;
                case 'p':
                    argparm = &s_opt_pass;
                    break;
                case 'V':
                    argparm = &s_opt_vhost;
                    break;
                case 'e':
                    argparm = &s_opt_command;
                    break;
                case 't':
                    argparm = &s_opt_trace;
                    break;
                case 'x':
                    argparm = &s_opt_xml;
                    break;
                case 'b':
                    s_opt_broker = TRUE;
                    break;
                case 'c':
                    s_opt_clients = TRUE;
                    break;
                case 'r':
                    s_opt_report = TRUE;
                    break;
                case 'a':
                    s_opt_addr = TRUE;
                    break;
                case 'd':
                    s_opt_date = TRUE;
                    break;
                case 'v':
                    printf (PRODUCT "\n");
                    printf (COPYRIGHT "\n");
                    printf (BUILDMODEL "\n");
                    printf ("Built on: " BUILDDATE "\n");
#if defined (CCOPTS)
                    printf ("Compiler: " CCOPTS "\n");
#endif
                    exit (EXIT_SUCCESS);
                case 'h':
                    printf (PRODUCT "\n");
                    printf (BUILDMODEL "\n\n");
                    printf (COPYRIGHT "\n");
                    printf (NOWARRANTY);
                    printf (USAGE);
                    exit (EXIT_SUCCESS);
                //  Anything else is an error
                default:
                    args_ok = FALSE;
            }
        }
        else {
            args_ok = FALSE;
            break;
        }
    }
    //  Initialise global class so we can use the console
    icl_system_initialise (argc, argv);

    printf ("amq_shell/%s - Management Console for OpenAMQ Brokers\n", VERSION);
    printf (COPYRIGHT "\n\n");

    icl_console_mode (ICL_CONSOLE_DATE, s_opt_date);
    icl_console_mode (ICL_CONSOLE_TIME, s_opt_date);

    //  If there was a missing parameter or an argument error, quit
    if (argparm) {
        icl_console_print ("E: argument missing - use '-h' option for help");
        exit (EXIT_FAILURE);
    }
    else
    if (!args_ok) {
        icl_console_print ("E: invalid arguments - use '-h' option for help");
        exit (EXIT_FAILURE);
    }
    //  Default connection values
    if (!s_opt_host)
        s_opt_host = "localhost";
    if (!s_opt_user)
        s_opt_user = "******";
    if (!s_opt_pass)
        s_opt_pass = "******";
    if (!s_opt_vhost)
        s_opt_vhost = "/";
    if (!s_opt_trace)
        s_opt_trace = "0";

    if (s_opt_report)
        s_do_authenticated_port_scan (s_opt_host, s_opt_vhost, s_opt_user, s_opt_pass);

    //  Set global options
    g_opt_trace = atoi (s_opt_trace);
    g_opt_addr  = s_opt_addr;

    console = amq_mgt_console_new (s_opt_host, s_opt_vhost, s_opt_user, s_opt_pass);
    if (!console)
        exit (EXIT_FAILURE);

    icl_console_out ("Connected to %s/%s on %s\n",
        console->connection->server_product,
        console->connection->server_version,
        console->connection->server_host);

    if (s_opt_xml) {
        xml_data = fopen (s_opt_xml, "w");
        fprintf (xml_data, "<?xml?>\n");
        fprintf (xml_data, "<console_data>\n");
    }
    //  Either dump broker state and exit, or do full command line
    if (s_opt_broker) {
        amq_mgt_broker_print_properties (console->broker, xml_data);
        amq_mgt_broker_print_children   (console->broker, xml_data);
    }
    else
    if (s_opt_clients) {
        amq_mgt_connection_t
            *connection;                //  Child connection
        amq_mgt_broker_load (console->broker);

        connection = amq_mgt_broker_connection_first (console->broker);
        while (connection) {
            amq_mgt_connection_load (connection);
            amq_mgt_connection_print_summary (connection, xml_data);
            connection = amq_mgt_broker_connection_next (console->broker);
        }
    }
    else {
        if (s_opt_command)
            tokens = ipr_token_split_rich (s_opt_command, ";");
        else
            tokens = NULL;

        amq_mgt_broker_cmdline (console->broker, console->connection->server_host, 0, tokens, xml_data);
        ipr_token_list_destroy (&tokens);
    }
    if (s_opt_xml) {
        fprintf (xml_data, "</console_data>\n");
        fclose (xml_data);
    }
    amq_mgt_console_destroy (&console);

    icl_system_terminate ();            //  Terminate all classes
    return (EXIT_SUCCESS);
}
示例#7
0
void Init_rwire()
{
	icl_system_initialise(0, NULL);


	cRWire      = rb_define_module("RWire");
	cConnection = rb_define_class_under(cRWire, "Connection", rb_cObject);
	cSession    = rb_define_class_under(cRWire, "Session",    rb_cObject);
	cContent    = rb_define_class_under(cRWire, "Content",    rb_cObject);
	eAMQError   = rb_define_class("AMQError", rb_eRuntimeError);
	eAMQDestroyedError = rb_define_class("AMQDestroyedError", eAMQError);

	// RWire
	rb_define_method(cRWire, "initialize", rwire_init, 1); //initialize(trace_levoel)

	// Content
	rb_define_alloc_func(cContent, rwire_amq_content_basic_alloc);
	rb_define_method(cContent, "unlink",  rwire_amq_content_basic_unlink, 0);

	RB_DEF_CONTENT_ATTR(body);
	RB_DEF_CONTENT_ATTR(message_id);

	RB_DEF_CONTENT_ATTR(reply_to);

	RB_DEF_CONTENT_GETTER(exchange);
	RB_DEF_CONTENT_GETTER(routing_key);

	// TODO: Set routing key requires multiple arguments
	// Not terribly useful since routing key is usually set when sending message
	//rb_define_method(cContent, "routing_key=", rwire_amq_content_basic_set_routing_key, 1);

	RB_DEF_CONTENT_ATTR(content_type);
	RB_DEF_CONTENT_ATTR(content_encoding);
	RB_DEF_CONTENT_ATTR(correlation_id);
	RB_DEF_CONTENT_ATTR(expiration);
	RB_DEF_CONTENT_ATTR(user_id);
	RB_DEF_CONTENT_ATTR(app_id);

	RB_DEF_CONTENT_GETTER(body_size);
	RB_DEF_CONTENT_GETTER(class_id);
	RB_DEF_CONTENT_ATTR(priority);
	RB_DEF_CONTENT_ATTR(delivery_mode);
	RB_DEF_CONTENT_ATTR(timestamp);


	// No support for headers yet.	Need more thoughts on this. Should
	// probably expose this separately

	//rb_define_method(cContent, "headers", rwire_amq_content_basic_get_headers, 0);
	//rb_define_method(cContent, "content_basic_set_headers", rwire_amq_content_basic_set_headers, 0);

	// AMQ message type.	Is it even useful to expose it?	If do, needs to pick a
	// different name to avoid conflict with the Ruby type method

	//rb_define_method(cContent, "type", rwire_amq_content_basic_get_type, 0);
	//rb_define_method(cContent, "content_basic_set_type", rwire_amq_content_basic_set_type, 0);

// Connection
	rb_define_alloc_func(cConnection, rwire_connection_alloc);
	rb_define_method(cConnection, "initialize", rwire_connection_init, 7);
	rb_define_method(cConnection, "session_new", rwire_amq_client_session_new, 0);

	// rb_define_method(cConnection, "wait", rwire_amq_client_connection_wait, 1);
	// rb_define_method(cConnection, "selftest", rwire_amq_client_connection_selftest, 0);

	rb_define_method(cConnection, "destroy", rwire_connection_destroy, 0);

	RB_DEF_CONN_BOOL_ATTR(silent);
	RB_DEF_CONN_BOOL_GETTER(alive);
	RB_DEF_CONN_GETTER(channel_max);
	RB_DEF_CONN_GETTER(class_id);
	RB_DEF_CONN_GETTER(error_text);
	RB_DEF_CONN_GETTER(frame_max);
	RB_DEF_CONN_GETTER(heartbeat);
	RB_DEF_CONN_GETTER(known_hosts);
	RB_DEF_CONN_GETTER(method_id);
	RB_DEF_CONN_GETTER(reply_code);
	RB_DEF_CONN_GETTER(reply_text);
	RB_DEF_CONN_GETTER(version_major);
	RB_DEF_CONN_GETTER(version_minor);

// Session
	RB_DEF_SESS_METHOD(destroy, 0);
	RB_DEF_SESS_METHOD(wait, 1); // timeout
	RB_DEF_SESS_GETTER(basic_arrived);
	RB_DEF_SESS_GETTER(basic_arrived_count);
	RB_DEF_SESS_GETTER(basic_returned);
	RB_DEF_SESS_GETTER(basic_returned_count);
	RB_DEF_SESS_BOOL_GETTER(alive);

	//RB_DEF_SESS_METHOD(channel_flow, 0);
	//RB_DEF_SESS_METHOD(access_request, 0);
	RB_DEF_SESS_METHOD(declare_exchange, 6);
	//RB_DEF_SESS_METHOD(exchange_delete, 0);
	RB_DEF_SESS_METHOD(declare_queue, 5);
	RB_DEF_SESS_METHOD(delete_queue, 3);
	RB_DEF_SESS_METHOD(bind_queue, 3);
	//RB_DEF_SESS_METHOD(queue_unbind, 0);
	//RB_DEF_SESS_METHOD(queue_purge, 0);
	//RB_DEF_SESS_METHOD(queue_delete, 0);
	RB_DEF_SESS_METHOD(consume, 5);
	RB_DEF_SESS_METHOD(basic_cancel, 1);
	RB_DEF_SESS_METHOD(publish_body, 6);
	RB_DEF_SESS_METHOD(publish_content, 5);
	//RB_DEF_SESS_METHOD(basic_ack, 0);
	//RB_DEF_SESS_METHOD(basic_reject, 0);
	RB_DEF_SESS_METHOD(basic_get, 1);

	//RB_DEF_SESS_BOOL_GETTER(silent);
	RB_DEF_SESS_GETTER(error_text);
	//RB_DEF_SESS_GETTER(ticket);
	RB_DEF_SESS_GETTER(queue);
	RB_DEF_SESS_GETTER(exchange);
	RB_DEF_SESS_GETTER(message_count);
	//RB_DEF_SESS_GETTER(consumer_count);
	//RB_DEF_SESS_BOOL_GETTER(active);
	RB_DEF_SESS_GETTER(reply_text);
	RB_DEF_SESS_GETTER(reply_code);
	RB_DEF_SESS_GETTER(consumer_tag);
	//RB_DEF_SESS_GETTER(routing_key);
	//RB_DEF_SESS_GETTER(scope);
	//RB_DEF_SESS_GETTER(delivery_tag);
	//RB_DEF_SESS_BOOL_GETTER(redelivered);
}