eandersson / amqpstorm

Thread-safe Python RabbitMQ Client & Management library
https://www.amqpstorm.io/
MIT License
186 stars 36 forks source link

Robust Connection example #91

Open jmcarter opened 3 years ago

jmcarter commented 3 years ago

Hi,

This is more of a question than an issue - is it possible to be able to manage a long-lived connection such that a reconnection can be immediately attempted if the channel/connection is closed?

I see the robust consumer example, but nothing for a connection that maybe used just for publishing. I don't see the ability to add any callbacks for a closed connection or a way to block the current thread until there's an error on the connection/channel, or maybe I'm just missing something.

Thanks for any help in advance.

eandersson commented 3 years ago

This isn't currently supported, but not a bad idea. The problem is that a channel event is in reality triggered when a function is executed, especially if it is a connection level event.

Maybe for publishing something like amqpstorm-pool is a better pattern? It would allow you to use a "pool" of connections, and if one is bad just use the next connection? https://github.com/eandersson/amqpstorm-pool

frankiedrake commented 2 years ago

Having the same question, would be great to have some reconnactable ability "out-of-the-box" that will try to publish a message and recover the connection/channel in case of error in background

eandersson commented 2 years ago

Having the same question, would be great to have some reconnactable ability "out-of-the-box" that will try to publish a message and recover the connection/channel in case of error in background

Are you just looking for something similar to the robust consumer example, but for publishing, or would prefer something backed into the library?

sunu commented 2 years ago

I would love to see an example similar to the robust consumer example for publishing.