[rabbitmq-discuss] Channel Cost

Barry Pederson bp at barryp.org
Tue Jan 27 22:16:37 GMT 2009


Jason J. W. Williams wrote:
> Hi Barry,
> 
> chan_send.basic_publish(msg,exchange=args.exchange,routing_key=args.routing_key)
> to an exchange that doesn't exist. I was just wrapping that in a
> try/except, assuming it would raise AMQPChannelError if there was an
> issue. Unfortunately, it doesn't look like basic_publish has any logic
> for checking for an error.

Would it make more sense to do an exchange_declare() with passive=True 
to check for the existence of the exchange you're going to publish to? 
The PyDocs for Channel.exchange_declare() say:

-----------
   passive: boolean

       do not create exchange

       If set, the server will not create the exchange.  The
       client can use this to check whether an exchange
       exists without modifying the server state.

       RULE:

           If set, and the exchange does not already exist,
           the server MUST raise a channel exception with
           reply code 404 (not found).
-------------


	Barry




More information about the rabbitmq-discuss mailing list