<br><br><div class="gmail_quote">On Mon, Jan 24, 2011 at 3:17 PM, Matthias Radestock <span dir="ltr">&lt;<a href="mailto:matthias@rabbitmq.com">matthias@rabbitmq.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Sam Duncan wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If you use a topic exchange and create a queue for each consumer, you get a copy of each message in each queue filtered by your queue bindings.<br></blockquote></div></blockquote><div><br></div><div>I tried this, but it still didn&#39;t seem to work.</div>
<div>�</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

</blockquote>
<br></div>
A direct exchange would probably work too, unless you need bindings with wildcards.<br>
<br>
If you haven&#39;t done so already, I recommend reading <a href="http://www.rabbitmq.com/tutorial-three-python.html" target="_blank">http://www.rabbitmq.com/tutorial-three-python.html</a><br>
<br></blockquote><div><br></div><div>I have read this, thanks.�</div><div><br></div><div>Here is an attempt that uses two fanout exchanges and two queues, one bound to each exchange with &#39;#&#39;. 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.</div>
<div><br></div><div>However, what happens in practice is only one receiver at a time gets a message.</div><div><br></div><div>Fire up two (or more) instances of app2.py and then run app1.py (which currently just sends a message and exits). How can I change this so that all the instances of app2.py receive all messages sent through the &#39;from_web_exchange&#39;?</div>
<div><br></div><div>app1.py:</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">#!/usr/bin/env python</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">import pika</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">connection = pika.AsyncoreConnection(pika.ConnectionParameters(</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� � � �host=&#39;localhost&#39;))</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">channel = connection.channel()</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from_web_exchange = channel.exchange_declare(exchange=&quot;from_web_exchange&quot;,type=&quot;fanout&quot;)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from_worker_exchange = channel.exchange_declare(exchange=&quot;from_worker_exchange&quot;, type=&#39;fanout&#39;)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br>
</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from_builders_queue = channel.queue_declare(queue=&#39;frombuilders&#39;, auto_delete=True)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from_web_queue = channel.queue_declare(queue=&#39;fromweb&#39;, auto_delete=True)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">channel.queue_bind(exchange=&#39;from_web_exchange&#39;, queue=from_web_queue.queue, routing_key=&quot;#&quot;)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">channel.queue_bind(exchange=&#39;from_worker_exchange&#39;, queue=from_builders_queue.queue, routing_key=&quot;#&quot;)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">channel.basic_publish(exchange=&#39;from_web_exchange&#39;,</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� � � � � � � � � � �routing_key=&#39;does_it_matter&#39;,</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� � � � � � � � � � �body=&#39;Hello World!&#39;)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">print &quot; [x] Sent &#39;Hello World!&#39;&quot;</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">connection.close()</font></div>
</div><div><br></div><div>app2.py:</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">#!/usr/bin/env python</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">import pika</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">import sys</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">connection = pika.AsyncoreConnection(pika.ConnectionParameters(</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� � � �host=&#39;localhost&#39;))</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">channel = connection.channel()</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br>
</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from_web_exchange = channel.exchange_declare(exchange=&quot;from_web_exchange&quot;,type=&quot;fanout&quot;)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from_worker_exchange = channel.exchange_declare(exchange=&quot;from_worker_exchange&quot;, type=&#39;fanout&#39;)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from_builders_queue = channel.queue_declare(queue=&#39;frombuilders&#39;, auto_delete=True)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from_web_queue = channel.queue_declare(queue=&#39;fromweb&#39;, auto_delete=True)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">channel.queue_bind(exchange=&#39;from_web_exchange&#39;, queue=from_web_queue.queue, routing_key=&quot;#&quot;)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">channel.queue_bind(exchange=&#39;from_worker_exchange&#39;, queue=from_builders_queue.queue, routing_key=&quot;#&quot;)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br>
</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">#channel.queue_declare(queue=&#39;hello&#39;)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">print &#39; [*] Waiting for messages. To exit press CTRL+C&#39;</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">arg = &quot;No-arg&quot;</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">#print len(sys.argv)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">if (len(sys.argv) == 2):</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� �arg = sys.argv[1]</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">def callback(ch, method, properties, body):</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� �print &quot; [x] Received %r&quot; % (body,)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� �channel.basic_publish(exchange=&#39;from_worker_exchange&#39;,</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� � � � � � � � � � � � �routing_key=&quot;#&quot;, # key.frombuilders</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� � � � � � � � � � � � �body= arg + &quot; python approves of &quot; + body)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� �</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">channel.basic_consume(callback,</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� � � � � � � � � � �queue=from_web_queue.queue,</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">�� � � � � � � � � � �no_ack=True)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">pika.asyncore_loop()</font></div><div><br></div></div>
<div>�<br>Thanks in advance,</div><div>Dan</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Regards,<br><font color="#888888">
<br>
Matthias.</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</div></div></blockquote></div><br>