<br><br><div class="gmail_quote">On Tue, Jan 25, 2011 at 10:35 AM, Marek Majkowski <span dir="ltr"><<a href="mailto:majek04@gmail.com">majek04@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Tue, Jan 25, 2011 at 18:22, Dan Tenenbaum <<a href="mailto:dtenenba@fhcrc.org">dtenenba@fhcrc.org</a>> wrote:<br>
>> If you haven't done so already, I recommend reading<br>
>> <a href="http://www.rabbitmq.com/tutorial-three-python.html" target="_blank">http://www.rabbitmq.com/tutorial-three-python.html</a><br>
>><br>
><br>
> I have read this, thanks.<br>
> Here is an attempt that uses two fanout exchanges and two queues, one bound<br>
> to each exchange with '#'. You would think (well, I would think) that any<br>
> message sent to either of these fanout exchanges is going to go to every<br>
> consumer of every queue bound to the appropriate exchange.<br>
<br>
</div>If N messages go to the queue, exactly N messages will go out, no<br>
matter how many consumers are hanging on that queue.<br>
<br>
If N messages go to the exchange, any number may go out, depending on bindings.<br>
<br>
Exchanges - broadcast.<br>
Queues - buffering.<br>
<div class="im"><br></div></blockquote><div><br></div><div>I think I understand this. That's why in my code, I publish messages to an exchange, not a queue.</div><div><br></div><div>I am looking at the python example 3 code on the rabbitmq site (<a href="http://www.rabbitmq.com/tutorial-three-python.html">http://www.rabbitmq.com/tutorial-three-python.html</a>). 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. </div>
<div><br></div><div>I got my code to work by using an un-named exclusive queue in each receiver:</div><div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">from_builders_queue = channel.queue_declare(exclusive=True)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">from_builders_queue_name = from_builders_queue.queue</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div><div><font class="Apple-style-span" face="'courier new', monospace">from_web_queue = channel.queue_declare(exclusive=True)</font></div><div><font class="Apple-style-span" face="'courier new', monospace">from_web_queue_name = from_web_queue.queue</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">channel.queue_bind(exchange='from_web_exchange', queue=from_web_queue_name)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">channel.queue_bind(exchange='from_worker_exchange', queue=from_builders_queue_name)</font></div></div><div><br></div><div><br></div><div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">
> However, what happens in practice is only one receiver at a time gets a<br>
> message.<br>
<br>
</div>You need to have exactly as many queues as many copies of the message<br>
you'd like to receive.<br>
<br>
Once again: a message distributed to queue will not be copied to<br>
multiple consumers. It will<br>
be distributed to a single consumer only.<br>
<br></blockquote><div><br></div><div>Thanks for your help.</div><div>Dan</div><div><br></div></div>