[rabbitmq-discuss] Load Balancing Consumers

Matthew Sackman matthew at rabbitmq.com
Thu Sep 8 15:22:39 BST 2011


Hi Uday,

On Thu, Sep 08, 2011 at 07:18:51AM -0700, Uday Subbarayan wrote:
>          I have a need to load balance consumers on a queue. I saw a similar thread last month-
> http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2011-August/014533.html
> 
> My requirements are little different. Publisher ----> sends messages ---> Queue <------ 1 or more consumers listens on this queue.
> 
> All my consumers are the same application. I need to load balance(simple round robin) the consumers so that my load gets distributed. For example if i have 2 consumers and publishers sends 2 messages to the queue, message 1 should go to consumer 1 and message 2 should to consumer 2 and this logic repeats.
> 
> Any idea/thoughts how i can achieve this in Rabbit MQ?

In your application, in both consumers, before issuing the
basic.consume, issue a basic.qos with prefect_count = 1. Make sure you
are not using no_ack = true (i.e. you are explicitly acking messages you
receive).

Matthew


More information about the rabbitmq-discuss mailing list