[rabbitmq-discuss] How to achieve HA consumers?

Matthias Radestock matthias at rabbitmq.com
Fri Aug 31 12:39:47 BST 2012


On 31/08/12 12:27, Francesco Mazzoli wrote:
>    * The second consumer polls the first in some way and starts consuming when it
>      realises the first consumer is dead.  This is simple and should serve you
>      right, but it's not that nice performance wise.

A passive queue.declare, which returns the consumer_count could 
accomplish this. You'd need to be mindful of races when consumers start up.

>    * You create a second queue that we'll call "token queue", and you publish one
>      dummy message in it, with acks enabled.  Then, a consumer wishing to consume
>      from your queue, will:
>
>        - Consume from the token queue

More specifically, start consuming and wait for the token message to 
arrive. And then...

>        - Start consuming from the actual queue
>        - When shutting down, publish a dummy message to the token queue

No need for the last step (and in fact it will lead to token 
duplication). Simply leave the message unack'ed and let the automatic 
requeue on connection closure/failure take care of the rest.

Matthias.


More information about the rabbitmq-discuss mailing list