[rabbitmq-discuss] How to achieve HA consumers?

Matthias Radestock matthias at rabbitmq.com
Wed Sep 5 08:48:09 BST 2012


On 05/09/12 05:32, johnson wrote:
> The channel.queueDeclarePassive method returns the consumer count of
>  the specified channel,

No it doesn't. queue.declarePassive returns the total number of active
consumers of the queue at that point in time. Regardless of what
connection/channel they were created on.

That should be pretty clear from the docs -
- which make no mention of the count being connection/channel specific.

> So if I start two consumers [...] in two different machines [...] the
> channel.queueDeclarePassive method always return the consumer count
> == 1, not 2.

I am not sure what you are expecting to see here. If you start two
consumers, the count they will see prior to consuming will be 0 or 1.

As mentioned "You'd need to be mindful of races when consumers start 
up.", i.e. if both consumers start up near simultaneously then they will 
both see a count of 0.

> I also try to find a API that can retrieve the existing connection or
> channel. Then the second consumer can reuse the connection or channel
> the first consumer created. But it seems no such APIs.

A connection represents a point-to-point TCP connection. You can't 
"reuse" that from a third point.



More information about the rabbitmq-discuss mailing list