[rabbitmq-discuss] Exclusive Producers?

Alvaro Videla videlalvaro at gmail.com
Tue Feb 18 10:23:27 GMT 2014


Maybe there's an easier solution, but you could try this:

- Create a queue called "lock" (or whatever name suits you) and
publish just one message to it, which will be the token producers need
to obtain in order to publish messages.
- Start your producers and make them consume just one message from
that queue, ie basic_qos(prefetch-count=1), also tell RabbitMQ that
you will ack the messages. The first producer arriving at the queue
will grab the "token". The other producers will sit idle, waiting for
said token.
- When the producer receives the "token", then it can start publishing
to the actual queue where you want the messages.
- If that consumer crashes or is shut down, then the "token" will be
requeued and some other of your backup producers will grab it, so it
can start publishing.
- if the producer wishes to stop, it can basic_reject(requeue=true)
the "token", so another producer can grab it and start publishing.



On Tue, Feb 18, 2014 at 3:06 AM, Tarun Mistry <tarun.mistry at gmail.com> wrote:
> Hi all,
> i'm new to RabbitMQ/AMQP. I am trying to solve an application level
> high-availability problem and belive i'm not thinking about things in the
> right way, I could use some advice!
> Here is what I would like to achieve, I could use some help understanding
> the RabbitMQ way of doing it.
> 1) I have several message producers, only 1 of these is the primary, the
> remainder as all backups.
> 2) The primary is defined as the process that controls a single queue and
> can post messages to it.
> 3) If the primary process fails, I want a backup to take over immediately.
> 4) All backups are in a race to get control of the queue (from 2)
> 5) Once a backup gains control, it is now the primary.
> Using Rabbit speak, I feel like I need something called an "exclusive
> producer".
> 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?
> Appreciate any advice
> Cheers
> TM
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

More information about the rabbitmq-discuss mailing list