[rabbitmq-discuss] Pika - Catch amqp error - Cannot redeclare exchange with different type

Jerry Kuch jerryk at vmware.com
Tue Feb 7 16:34:27 GMT 2012


Hi, Raphael:

This is actually a behavior defined in the AMQP specification.
AMQP allows applications quite a free hand (within the bounds
of permissions) to declare elements of their messaging fabric
such as queues, exchanges and the bindings between them.

A common idiom in AMQP programs is to defensively declare a
resource you're about to use prior to its use.  If the resource
already exists, and its properties entirely agree with what
you're asking for, the operation succeeds idempotently and life
goes on.  If, however, there was already an entity with the
given name, but different properties, it's not safe to toss the
old one and create you a new one (who else might be using it?)
so you end up with 404/not-found.

If you really want a new entity with new properties, you'll have
to delete the old one and create anew...

Best regards,
Jerry

----- Original Message -----
From: "Raphaël De GIUSTI" <raphael.degiusti at guardis.com>
To: rabbitmq-discuss at lists.rabbitmq.com
Sent: Tuesday, February 7, 2012 5:42:37 AM
Subject: [rabbitmq-discuss] Pika - Catch amqp error - Cannot redeclare	exchange with different type


Hi,


I'm using Pika 0.9.5 with python 2.7 successfully, but I'm running into some issues when it comes to handle errors from the RabbitMQ broker.
I would like to deal programmatically with errors of this kind :



=ERROR REPORT==== 7-Feb-2012::14:13:40 ===
connection <0.25027.3>, channel 1 - error:
{amqp_error,precondition_failed,
"cannot redeclare exchange 'status' in vhost '/' with different type, durable, internal or autodelete value",
'exchange.declare'}


This log is from the rabbitmq log.


I'm using the Pika SelectConnection, and my app is hanging somewhere after calling channel.exchange_declare and never gets into my callback.



def on_channel_open(channel):
channel.exchange_declare(
exchange="status",
callback=on_exchange_declared)


What would be the way, in this case (and more generally) to "catch" errors like this one in my code ?




Raphaël
_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss at lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list