Hi Nathan,<br><br>Would it be possible to detail a bit more about your use case, and thus why you don&#39;t know when exchanges will come and go? In most scenarios, we&#39;d recommend that you just declare the exchanges in a non-passive manner - but I take it that there is something special about your use case that prevents this.<br>
<br>If your requirement definitely does stand, there isn&#39;t really a cleaner way to do this from the queue-binding end. Speculating a bit on your use case, if you&#39;re trying to bind every exchange in your system to a single queue, would it be possible to perform the binding at the point of exchange creation (ie, instead of a queue binding to a well-known exchange, bind the exchange to a well-known queue).<br>
<br>Exchange-to-exchange bindings are still just a proposal at the moment I&#39;m afraid.<br><br>Thanks,<br>Paul.<br><br><div class="gmail_quote">On Tue, Aug 11, 2009 at 8:20 PM, Nathan Gray <span dir="ltr">&lt;<a href="mailto:n8gray@n8gray.org">n8gray@n8gray.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi folks,<br>
<br>
I&#39;m using rabbitmq as an event notification system. �In my application<br>
each client will subscribe to a number of exchanges. �Exchanges may<br>
come and go. �The client cannot be expected to know in advance which<br>
exchanges no longer exist, so they will use exchange.declare(...,<br>
passive=True,...) to find out which ones exist. �However,<br>
exchange.declare in passive mode raises a channel exception and kills<br>
the channel if the exchange doesn&#39;t exist. �Assuming I want to use one<br>
channel per client I&#39;m stuck with ugly, racy code to subscribe to<br>
multiple exchanges. �(See the end of the post for the python code to<br>
do it.) �And if something goes wrong and kills the channel I have to<br>
go through the whole dance again. �This seems crazy.<br>
<br>
My question is, what&#39;s the right way for one client to get messages<br>
from multiple exchanges? �Can one auto-delete queue be bound in<br>
multiple channels, and if so is that the proper approach? �Should I be<br>
making N queues &amp; channels to subscribe to N exchanges?<br>
<br>
Also, exchange-exchange binding [1] would solve a lot of problems for<br>
me -- does it work or is it just a proposal?<br>
<br>
Thanks,<br>
-n8<br>
<br>
--<br>
<a href="http://n8gray.org" target="_blank">http://n8gray.org</a><br>
<br>
[1]: <a href="https://dev.rabbitmq.com/wiki/ExchangeToExchangeBindings" target="_blank">https://dev.rabbitmq.com/wiki/ExchangeToExchangeBindings</a><br>
<br>
while True:<br>
 � �chan = connection.channel()<br>
 � �found = []<br>
 � �for xc in exchanges:<br>
 � � � �try:<br>
 � � � � � �chan.exchange_declare(exchange=xc, passive=True, ...)<br>
 � � � � � �found.append(xc)<br>
 � � � �except amqp.exceptions.AMQPChannelException, e:<br>
 � � � � � �if e.amqp_reply_code == 404:<br>
 � � � � � � � �# Channel got closed. �Open a new channel.<br>
 � � � � � � � �chan = connection.channel()<br>
 � � � � � �else:<br>
 � � � � � � � �raise e<br>
 � �# Sure hope nothing gets deleted at this point!<br>
 � �qname, _, _ = chan.queue_declare(exclusive=True)<br>
 � �try:<br>
 � � � �for xc in found:<br>
 � � � � � �chan.queue_bind(queue=qname, exchange=xc)<br>
 � �except amqp.exceptions.AMQPChannelException, e:<br>
 � � � �if e.amqp_reply_code == 404:<br>
 � � � � � �# Oops, an exchange got deleted. �Start over.<br>
 � � � � � �continue<br>
 � � � �else:<br>
 � � � � � �raise e<br>
 � �# No exception raised, so we&#39;re done (until something<br>
 � �# else goes wrong &amp; kills the channel...)<br>
 � �break<br>
<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</blockquote></div><br>