Listening Multiple Queues

2,509 views
Skip to first unread message

J Maharajan

unread,
May 18, 2015, 6:22:39 AM5/18/15
to rabbitm...@googlegroups.com
Hi,

I have a requirement, my application has to listen multiple queues example, 500 queues. What would be the best approach  using SimpleMessageListenerContainer.The message publishes using a direct exchange where message goes to the queues whose binding key exactly matches the routing key of the message in the exchange.

My question here, what should be the approach to listen all these queues and with in onMessage i have to read message from the respective queue.

Any help would be appreciated!

Thanks

Michael Klishin

unread,
May 18, 2015, 8:42:50 AM5/18/15
to J Maharajan, rabbitm...@googlegroups.com
Please direct Spring AMQP questions to  StackOverflow, tagged as spring-amqp.

With the Java client, you can reuse a single consumer 500 times when invoking Channel#basicConsume, or use a new instance every time if that is more convenient.

MK
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gary Russell

unread,
May 18, 2015, 8:55:40 AM5/18/15
to Michael Klishin, J Maharajan, rabbitm...@googlegroups.com
Same thing with Spring AMQP (one listener container, multiple queues or one container per queue, where each container can have any number of consumers). It's up to you.

We populate the MessageProperties with the consumer tag and the corresponding queue name (since 1.4.2) so when using the first case, you can figure out which queue a message came from.

J Maharajan

unread,
May 19, 2015, 12:54:27 AM5/19/15
to rabbitm...@googlegroups.com, mkli...@pivotal.io, j.mah...@gmail.com
Thank you Gary and Mk.

Can you please share the reference link/code snippets where i can see the implementation code if you have anything ?

Thanks in Advance.

Gary Russell

unread,
May 19, 2015, 3:12:37 AM5/19/15
to J Maharajan, rabbitm...@googlegroups.com, Michael Klishin
See the project home page [1]. It has links to documentation which in turn has links to samples.

The home page itself has a "quick start". Simply change


container.setQueueNames("myQueue");

to

container.setQueueNames("myQueue1, myQueue2");

or 

    <rabbit:listener ref="foo" method="listen" queue-names="myQueue" />

to

    <rabbit:listener ref="foo" method="listen" queue-names="myQueue1, myQueue2" />

when using XML configuration.



J Maharajan

unread,
May 19, 2015, 4:41:50 AM5/19/15
to rabbitm...@googlegroups.com, j.mah...@gmail.com, mkli...@pivotal.io
Thanks Gray for your quick reply on this. This is fine for configuring selected queues but my case is, i have many queues running in exchange and i do want to listen all queues in my application (It may be 100 to 500 queues based on the node capacity) and receive message when message posted in particular queue .

I have only one onMessage method in my class which should receive message when message get published in particular queue.

Note: I am using Spring Boot Amqp and  I do not have any xml configuration in my application all are auto-wired.

Hope you understand my need.

Thanks in Advance.

Gary Russell

unread,
May 19, 2015, 5:16:34 AM5/19/15
to J Maharajan, rabbitm...@googlegroups.com, Michael Klishin
As requested before, please move this discussion to Stack Overflow (spring-amqp tag). This group is for pure rabbitmq and not for Spring AMQP questions.

Please ask a question over there and explain in much more detail what you are trying to do, and show your configuration.

J Maharajan

unread,
May 19, 2015, 5:40:23 AM5/19/15
to rabbitm...@googlegroups.com, j.mah...@gmail.com
Got it Gary  http://blog-milind.blogspot.in/2011/02/how-to-create-queue-and-consumers.html
I will try this and get back to you in case if i need any help.

On Tuesday, May 19, 2015 at 2:11:50 PM UTC+5:30, J Maharajan wrote:
Thanks Gary for your quick reply on this. This is fine for configuring selected queues but my case is, i have many queues running in exchange and i do want to listen all queues in my application (It may be 100 to 500 queues based on the node capacity) and receive message when message posted in particular queue .
Reply all
Reply to author
Forward
0 new messages