Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement single-consumer-multi-queue model for rabbitMQ

Tags:

rabbitmq

enter image description here

I have found this image is very similar to my bussiness model. I need to split message to some queue. for some heavy work. I can add more worker thread for them. But for some no much heavy work. I can let single consumer to subscribe their message. But how to do that in rabbitMQ. Through their document. I just found that single-queue-multi-consumer model.

like image 322
pythonee Avatar asked Jul 06 '12 07:07

pythonee


People also ask

Can a RabbitMQ queue have multiple consumers?

Single active consumer allows to have only one consumer at a time consuming from a queue and to fail over to another registered consumer in case the active one is cancelled or dies. Consuming with only one consumer is useful when messages must be consumed and processed in the same order they arrive in the queue.

How do you consume multiple messages in RabbitMQ?

To increase the performance and to consume more messages at a time, do as follows: Open the "RabbitMQ connection" and go to the Event sources tab. In Advanced Settings > "Other Attributes:", add “concurrentConsumers” property. For instance: concurrentConsumers=10.

Can a queue have multiple consumers?

Support for multiple-consumer queues is a Message Queue feature (the JMS specification defines messaging behavior in the case of only one consumer accessing a queue). When multiple consumers access a queue, the load-balancing among them takes into account each consumer's capacity and message processing rate.


1 Answers

  1. You can add multiple workers to a queue
  2. There can be multiple queues bound to an exchange.

In RabbitMQ, the producer always sends the message to an exchange. So, in your case, I hope only one exchange is enough. If you want to load balance at the consumer side, you have the above said two options.

You can also read my article: https://techietweak.wordpress.com/2015/08/14/rabbitmq-a-cloud-based-message-oriented-middleware/

like image 156
Saravanan Subramanian Avatar answered Oct 05 '22 08:10

Saravanan Subramanian