static VALUE rwire_amq_client_session_consume(VALUE self, VALUE queuename, VALUE consumer_tag, VALUE no_local, VALUE no_ack, VALUE exclusive) { int result; amq_client_session_t *session = NULL; char *_queuename = NULL; char *_consumer_tag = NULL; bool _no_local = (no_local != Qfalse); bool _no_ack = (no_ack != Qfalse); bool _exclusive = (exclusive != Qfalse); if (queuename != Qnil) _queuename = StringValuePtr(queuename); if (consumer_tag != Qnil) _consumer_tag = StringValuePtr(consumer_tag); Data_Get_Struct(self, amq_client_session_t, session); result = amq_client_session_basic_consume(session, 0, _queuename, _consumer_tag, _no_local, _no_ack, _exclusive, NULL); //TODO check for a more useful value to return return self; }
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); }