[rabbitmq-discuss] Single Queue With Multiple Consumers

2,357 views
Skip to first unread message

DarthMaul

unread,
Jul 15, 2011, 10:06:18 PM7/15/11
to rabbitmq...@lists.rabbitmq.com
I would like to implement a messaging strategy in RabbitMQ that seems
really simple, but I can't figure out how to configure it.
Essentially, I want to have all message producers send messages to a
single queue. Meanwhile, there are any number of message consumers
ready to consume messages off the queue, but each message should be
processed only once.

So lets say you have 1 producer, 20 messages, and 5 consumers. I want
each consumer to be "assigned" one message to start it off, so 15
messages are left. Then as each consumer gets done, he grabs the next
one. And so on.

Essentially, this is what happens at your local bank--one line and
multiple tellers.

Any insight into how to pull this off--or a better approach
altogether--is appreciated.

Thanks.
_______________________________________________
rabbitmq-discuss mailing list
rabbitmq...@lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

Simone Busoli

unread,
Jul 16, 2011, 4:40:30 AM7/16/11
to DarthMaul, rabbitmq...@lists.rabbitmq.com

I think you can achieve this by simply using a single queue, having your producer publish directly to it and the consumers consuming from it. Does this make sense?

Matthias Radestock

unread,
Jul 16, 2011, 4:50:48 AM7/16/11
to rabbitmq...@lists.rabbitmq.com, DarthMaul
On 16/07/11 09:40, Simone Busoli wrote:
> On Jul 16, 2011 9:30 AM, "DarthMaul" <screec...@gmail.com> wrote:
> > So lets say you have 1 producer, 20 messages, and 5 consumers. I want
> > each consumer to be "assigned" one message to start it off, so 15
> > messages are left. Then as each consumer gets done, he grabs the next
> > one. And so on.
>
> I think you can achieve this by simply using a single queue, having your
> producer publish directly to it and the consumers consuming from it.

You'll also need to set the basic.qos prefetch to 1. See the section on
"Fair dispatch" in
http://www.rabbitmq.com/tutorials/tutorial-two-python.html.

Matthias.

Barış Velioğlu

unread,
Dec 27, 2017, 8:01:55 PM12/27/17
to rabbitmq-discuss
I dont know if the running style of rabbitmq changed over time but it does still fairly dispatch even if the prefectch count is more than 1. 
Reply all
Reply to author
Forward
0 new messages