-
Notifications
You must be signed in to change notification settings - Fork 5
Improve reconnection #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
314af4c
to
9b5d355
Compare
9f12f1c
to
e8b0683
Compare
e8b0683
to
c09162d
Compare
@@ -86,7 +87,7 @@ def main() -> None: | |||
queue_name = "example-queue" | |||
|
|||
print("connection to amqp server") | |||
environment = Environment("amqp://guest:guest@localhost:5672/") | |||
environment = Environment("amqp://guest:guest@localhost:5672/", reconnect=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of reconnect=True
, I would use something like:
https://github.com/rabbitmq/rabbitmq-amqp-go-client/blob/d84c3d22de34b767e55e68e4f0fc54137b506924/pkg/rabbitmqamqp/amqp_connection_recovery.go#L8
RecoveryConfiguration struct {
/*
ActiveRecovery Define if the recovery is activated.
If is not activated the connection will not try to createSender.
*/
ActiveRecovery bool
/*
BackOffReconnectInterval The time to wait before trying to createSender after a connection is closed.
time will be increased exponentially with each attempt.
Default is 5 seconds, each attempt will double the time.
The minimum value is 1 second. Avoid setting a value low values since it can cause a high
number of reconnection attempts.
*/
BackOffReconnectInterval time.Duration
/*
MaxReconnectAttempts The maximum number of reconnection attempts.
Default is 5.
The minimum value is 1.
*/
MaxReconnectAttempts int
to make the reconnections more configurable
@Gsantomaggio Hey, back to you for final review. I also implemented the backoff and max_attempt! |
2a753d4
to
03e30b6
Compare
03e30b6
to
067b3f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are just a couple ot things.
I would enable the recovery connection by default and also I would validate the values,
for example avoid the recconnetion time < 1 seconds
c25c94a
to
f599178
Compare
f599178
to
c5dae5f
Compare
@Gsantomaggio Done! Back to you! |
This PR improves the remote disconnection management, implementing a full automatic reconnection: