[rabbitmq-discuss] rabbitmq-c and rabbitmq 1.5.4

David Wragg david at rabbitmq.com
Fri May 28 12:06:49 BST 2010


Hi Brad,

bradleyd <brad.smith at fullspectrum.net> writes:
> I am trying to test rabbitmq-c with rabbitmq 1.5.4--I followed the 
> README in the src--I am running into issue testing the example 
> amqp_sendstring--I think this is the right one.  I can see the example 
> send info via ngrep to the mq server.  The problem is nothing shows up 
> in the que.  I am not sure I am even going about this in the right way.  
> This is what I am passing to amqp_sendstring:
> ./amqp_sendstring remotehost 5672 amq.direct helloworld foobar
> I am using Ruby's amqp(6.7) gem as the consumer.

First of all, note that rabbitmq 1.5.4 is quite old - the current
version is 1.7.2.  While this is unlikely to be the source of your
problem, I'd strongly recommend upgrading.

I suspect the issue is that you haven't bound your queue.  Your
amqp_sendstring command is publishing the string "foobar" to the
"amq.direct" exchange with the routing key "helloworld".  While the AMQP
spec says that the borker should automatically supply a direct exchange
called "amq.direct", applications still have to bind queues to that
exchange if they want messages going to the exchange to appear on
queues.

This is in contrast to the nameless exchange, to which queues are
automatically bound.

I can illustrate the difference using the amqp-consume utility that is
now supplied with rabbitmq-c.

If I ask amqp-consume to consume from a queue "myqueue" with the -q option

    $ tools/amqp-consume -q myqueue cat

and leave it running, and then publish with your command

    $ examples/amqp_sendstring localhost 5672 amq.direct helloworld foobar

amqp-consume doesn't produce any output, because although it has created
the queue "myqueue", it has not bound it to any exchanges.

But if I now tell it to bind to "amq.direct" with the routing key "helloworld"

    $ tools/amqp-consume -q myqueue -e amq.direct -r helloworld cat

and publish again, it outputs "foobar".

Finally, to demonstrate the implicit binds of the nameless exchange, if
I once again consume from "myqueue" without binding it

    $ tools/amqp-consume -q myqueue cat

and the publish to the nameless exchange, using "myqueue" as the routing
key

    $ examples/amqp_sendstring localhost 5672 "" myqueue foobar

then the amqp-consume outputs "foobar".

You should be able to reproduce this behaviour using the Ruby amqp
client.  You can also use the rabbitmqctl utility supplied with
rabbitmq-server to check that your queues and bindings are set up as
expected.

David

-- 
David Wragg
Staff Engineer, RabbitMQ
SpringSource, a division of VMware



More information about the rabbitmq-discuss mailing list