aiormq icon indicating copy to clipboard operation
aiormq copied to clipboard

Documentation to handle disconnect/reconnect?

Open matutter opened this issue 6 years ago • 2 comments

Is there any documentation or examples on methods to handle disconnect / reconnect scenarios? Specifically I'm interested in typical or suggested patterns or even an explanation of the behavior of basic_send when the server disconnects.

Example: stomp.py has a on_receiver_loop_ended callback but that pattern probably isn't ideal with asyncio.

matutter avatar Sep 25 '19 12:09 matutter

All classes inherited from aiormq.base.Base has a self.closing future.

So you have two options, wait for it in a background task, or use .closing.add_done_callback(callback). It's might be applicable for channels or connections.

mosquito avatar Feb 15 '20 15:02 mosquito

Maybe we can bump this issue.

I have some questions on how to handle the case when RabbitMQ goes down.

So I am consuming messages over TCP in one task and sending them over to anotther task to publish on RabbitMQ.

If i turn off RabbitMQ, send a TCP message and do a basic publish the task hangs forever. When I turn off the RabbitMQ I get a "reader cancelled" debug output, but all errors are supressed so I cannot wait for that exception to reset the connection and start reconnect.

Right now I am solving it with ensuring the connection has a reader and a writer before the publish, but this could still fail.

I also don't get the TimeoutException from publish. This might be due to that in python 3.7 wait_for will still waits for the task to be cancelled (which seems to never happen) before they raise the TimeoutException

Any thoughts on how to make it a bit more robust? I can probably put in a PR but need som directions from maintainer on how they would like to fix it.

Krolken avatar Mar 11 '21 18:03 Krolken