[rabbitmq-discuss] Consumer Callback

fangbot fangbot at gmail.com
Wed Jul 20 23:26:00 BST 2011

I'm looking to create multiple publishers/subscribers from the main thread
that my program is run (i.e. the thread where I have declared my channel).
It seems that in the tutorials, the only way for consumers to get a message
from the queue its connected to is to explicitly call
consumer.nextDelivery(). However, as far as my understanding, in order to
constantly check for new publications, this call must reside within a
while(true) loop. 

Say I wanted to create a consumer with an anonymous queue and attach it to
an exchange. Then, I want to make a publication to that exchange. When that
publication is made, the consumer will print something to the console using
an overridden nextDelivery(). In order to do this, do I have to basically

1. Create the consumer/queue and attach it with a routingId to the exchange
2. Publish a method with that routingId to the exchange
3. Invoke the while loop to constantly check for messages

in that order?

If so, then is there a way to support two (or more) consumers to
automatically get nextDelivery? It seems that the only way is to write a
while loop that goes through every consumer, and calls nextDelivery on that
consumer, in an infinite loop. Instead, is there a way to create an event
such that when a queue gets pushed a message, it automatically calls
consumer.nextDelivery somehow?

Thanks in advance for the reply. I'm fairly new to RabbitMQ, so please
forgive me if the question is somewhat basic/has already been answered
elsewhere :-D.
View this message in context: http://old.nabble.com/Consumer-Callback-tp32103305p32103305.html
Sent from the RabbitMQ mailing list archive at Nabble.com.

More information about the rabbitmq-discuss mailing list