[zeromq-dev] amqp client mode from C
Martin Sustrik
sustrik at fastmq.com
Tue Jun 16 13:54:23 CEST 2009
Michael,
As far as I am aware, RabbitMQ currently implements AMQP/0.8 while 0MQ
implements AMQP/0.9.1 so the two won't speak together. There's should be
a 0.9.1 branch of RabbitMQ available somewhere though.
If you decide to go this way, you should be aware that AMQP support in
0MQ is rather simplisting. 0.6.1 version supports simple streaming of
messages to/from AMQP broker.
There's also a branch that supports creation of arbitrary wiring
(queues, exchanges, bindings) and dynamic setting of routing keys &
property tables for individual messages. The branch also eliminates the
need to zmq_server and connects directly to the AMQP server (port 5672):
http://svn.fastmq.org/svn/zeromq/branches/dj/
If you don't mind working with branches of both RabbitMQ and 0MQ, let us
know and let's give it a try.
Martin
Michael Nacos wrote:
> Hi
>
> according to the docs, there should be a way of connecting from zmq to
> an AMQP broker. I've been trying to achieve this using the zmq C API
> and things work fine, except that the AMQP broker, in this case
> RabbitMQ, is not used in the process
> (my message gets delivered whether RabbitMQ is running or not)
> zmq_server listens on its default 5682 port and the rabbit broker
> listens on 5672
>
> am I doing something wrong (except trying to use something besides
> zmq, as well :-)
>
> this is what I have got in the zmq_server config file:
>
> <root>
> <node name = "rabbit_E" location = "amqp://localhost:5672"/>
> <node name = "rabbit_Q" location = "amqp://localhost:5672"/>
> </root>
>
> and this is my C test code:
> ---------------------------------------------------------------------------------------------------------------------------------------------
> #include "stdio.h"
> #include "stdlib.h"
> #include "string.h"
> #include "zmq.h"
>
> int main() {
>
> void *object;
> void *message;
> uint64_t message_size;
> int eid;
> int qid;
>
> /* Initialise 0MQ infrastructure. */
>
> object = zmq_create("localhost:5682");
> eid = zmq_create_exchange (object, "rabbit_E", ZMQ_SCOPE_GLOBAL,
> "eth0", ZMQ_STYLE_LOAD_BALANCING);
> qid = zmq_create_queue (object, "rabbit_Q", ZMQ_SCOPE_GLOBAL,
> "eth0", ZMQ_NO_LIMIT, ZMQ_NO_LIMIT, ZMQ_NO_SWAP);
> zmq_bind (object, "rabbit_E", "rabbit_Q", NULL, NULL);
>
> /* Send a message. */
> message_size = strlen("This is a test");
> message = malloc (message_size + 1);
> strcpy(message, "This is a test");
> zmq_send (object, eid, message, message_size, ZMQ_TRUE);
> free (message);
>
> /* Receive a message */
> zmq_receive (object, &message, &message_size, NULL, ZMQ_TRUE);
> printf("%s\n", message);
> zmq_free (message);
>
> zmq_destroy(object);
> return 1;
> }
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list