Handle errors without closing connection

Asked by cybergrind

Hi all.
Hi all. I want to implement "redeclare exchange" for myself, but I lose connection every time, when get Error "530, NOT_ALLOWED - cannot redeclare exchange".
Is there any way to handle errors without closing connection?

Code:
try:
        yield channel.exchange_declare(exchange=name, type=type, durable=durable, auto_delete=auto_delete)
except Exception, mess:
        print 'E1: %s'%mess
        yield channel.exchange_delete(exchange=name) # here is another error: close [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
        yield channel.exchange_declare(exchange=name, type=type, durable=durable, auto_delete=auto_delete)

thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
txAMQP Edit question
Assignee:
No assignee Edit question
Solved by:
cybergrind
Solved:
Last query:
Last reply:
Revision history for this message
Esteve Fernandez (esteve) said :
#1

The AMQP spec says that errors will close the channel, so there's few txAMQP can do (Pieter Hintjens is one of the original authors of the AMQP spec):

http://lists.openamq.org/pipermail/openamq-dev/2008-January/000571.html

"AMQP likes brutal and unambiguous error handling. :-)"

This "brutal" error handling applies to practially any kind of error (exchange/queue redeclaration, removal of unknown exchanges/queues, etc.)

Revision history for this message
cybergrind (cybergrind) said :
#2

Hi Esteve,
Thanks for your answer.
Is there any way to reconnect (re-authenticate) easily with closed connection?
Thanks.

Revision history for this message
cybergrind (cybergrind) said :
#3