static VALUE rwire_amq_client_session_bind_queue(VALUE self, VALUE queuename, VALUE exchange, VALUE routing_key) { amq_client_session_t *session = NULL; char *_queuename = NULL; char *_exchange = StringValuePtr(exchange); char *_routing_key = StringValuePtr(routing_key); if (queuename != Qnil) _queuename = StringValuePtr(queuename); Data_Get_Struct(self, amq_client_session_t, session); amq_client_session_queue_bind(session, 0, _queuename, _exchange, _routing_key, 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); }