You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The listener API is the same for connection, publishers, and consumers.
64
-
They all implement the {javadoc-url}/com/rabbitmq/client/amqp/Resource.html[`Resource`] marker interface.
65
-
The {javadoc-url}/com/rabbitmq/client/amqp/Resource.StateListener.html[`StateListener`] interface has only one method that takes a {javadoc-url}/com/rabbitmq/client/amqp/Resource.Context.html[`Context`] argument.
66
-
See the snippet above for the information available in the `Context`.
67
-
68
-
A resource {javadoc-url}/com/rabbitmq/client/amqp/Resource.State.html[`State`] can have the following values: `OPENING`, `OPEN`, `RECOVERING`, `CLOSING`, `CLOSED`.
69
-
70
-
=== Recovery
71
-
72
-
Automatic connection recovery is activated by default: the client will automatically restore a connection after an unexpected closing (e.g. network glitch, node restart, etc).
73
-
Automatic topology recovery is also activated as soon as connection recovery is: the client will recreate AMQP entities, as well as publishers and consumers for the recovering connection.
74
-
Developers have less to worry about network stability and node restart, as the client will take care of it.
75
-
76
-
The client tries to reconnect every 5 seconds until it succeeds.
77
-
It is possible to change this behavior by providing a custom {javadoc-url}/com/rabbitmq/client/amqp/BackOffDelayPolicy.html[`BackOffDelayPolicy`]:
78
-
79
-
.Setting a back-off policy for connection recovery
It is also possible to deactivate topology recovery if it is not appropriate for a given application.
88
-
The application would usually register a connection <<lifecycle-listeners,lifecycle listener>> to know when the connection is recovered and recover its own state accordingly.
0 commit comments