[rabbitmq-discuss] Making sure a message gets to every consumer

Dan Tenenbaum dtenenba at fhcrc.org
Tue Jan 25 18:45:26 GMT 2011


On Tue, Jan 25, 2011 at 10:35 AM, Marek Majkowski <majek04 at gmail.com> wrote:

> On Tue, Jan 25, 2011 at 18:22, Dan Tenenbaum <dtenenba at fhcrc.org> wrote:
> >> If you haven't done so already, I recommend reading
> >> http://www.rabbitmq.com/tutorial-three-python.html
> >>
> >
> > I have read this, thanks.
> > Here is an attempt that uses two fanout exchanges and two queues, one
> bound
> > to each exchange with '#'. You would think (well, I would think) that any
> > message sent to either of these fanout exchanges is going to go to every
> > consumer of every queue bound to the appropriate exchange.
>
> If N messages go to the queue, exactly N messages will go out, no
> matter how many consumers are hanging on that queue.
>
> If N messages go to the exchange, any number may go out, depending on
> bindings.
>
> Exchanges - broadcast.
> Queues - buffering.
>
>
I think I understand this. That's why in my code, I publish messages to an
exchange, not a queue.

I am looking at the python example 3 code on the rabbitmq site (
http://www.rabbitmq.com/tutorial-three-python.html). If I run this code on
my own machine, with multiple instances of receive_logs.py, it works as I
would like my own code to work: each instance of receive_logs.py gets a copy
of each message sent by emit_logs.py.

I got my code to work by using an un-named exclusive queue in each receiver:

from_builders_queue = channel.queue_declare(exclusive=True)
from_builders_queue_name = from_builders_queue.queue

from_web_queue = channel.queue_declare(exclusive=True)
from_web_queue_name = from_web_queue.queue

channel.queue_bind(exchange='from_web_exchange', queue=from_web_queue_name)
channel.queue_bind(exchange='from_worker_exchange',
queue=from_builders_queue_name)




> > However, what happens in practice is only one receiver at a time gets a
> > message.
>
> You need to have exactly as many queues as many copies of the message
> you'd like to receive.
>
> Once again: a message distributed to queue will not be copied to
> multiple consumers. It will
> be distributed to a single consumer only.
>
>
Thanks for your help.
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110125/8d44229e/attachment-0001.htm>


More information about the rabbitmq-discuss mailing list