aio-pika icon indicating copy to clipboard operation
aio-pika copied to clipboard

Does RobustConnection handle reconnection and rebuild channels, exchanges, queues, bindings?

Open jalvespinto opened this issue 1 year ago • 1 comments

I am starting to learn rabbitmq and I read in the book "RabbitMQ in Action" that I should handle on my consumer the reconnection and rebuilding of resources basically through the use of a while loop and try, exception block. Now, it seems to me that RobustConnection is capable of doing just that automatically. Is that right? tks

jalvespinto avatar Apr 12 '23 20:04 jalvespinto

@jalvespinto sure! Here _on_close callback triggers a restore function, that triggers some nested functions, and, finally this function, that restores all exchanges and queues. Queues in their turn restore all bindings and consumers by their restore method. So, there no any magic. But, you should be accurate with: all objects to restore are stores as a WeakRefs. So, if your queue or smth was declared in any function and out of scope now, it will not be restored. I had an Issue in my project that reason.

Lancetnik avatar Jun 29 '23 20:06 Lancetnik