[rabbitmq-discuss] Exclusive Producers?
gsim at redhat.com
Tue Feb 18 10:31:13 GMT 2014
On 02/18/2014 10:18 AM, Simon MacMullen wrote:
> On 18/02/2014 2:06AM, Tarun Mistry wrote:
>> Using Rabbit speak, I feel like I need something called an "exclusive
> Yes, that sounds right. Sadly there's not really such a thing as a
> "producer" in the sense of a client having agreed that it can produce
> messages - there are just clients that may or may not publish messages.
> So there's an asymmetry with consumers there.
>> Do I need to fudge this by introducing a second queue and having all the
>> processes connect to this using the "exclusive consumer" pattern, and
>> then use this to determine who can control the main queue?
> So that's probably your best bet. I can't think of anything better,
> anyway. It's a bit ugly, but should be workable.
What I often do in cases like that is have the second queue as you
suggest, but instead of using an 'exclusive consumer' lock on it, just
have a single message in it. The consumer compete to get that one
message, when its delivered it indicates that the receiver has control.
The receiver doesn't acknowledge the message however. That means if/when
the current controller dies, the message will be automatically requeued
and redelivered to one of the backups. (Saves the backups having to
continually poll for ability to consume).
(And just in passing, I'll note that AMQP 1.0 did introduce the concept
of 'producer' of incoming messages - i.e. a sending link - analogous to
that of consumer of outgoing messages - i.e. a receiving link).
More information about the rabbitmq-discuss