Skip to content

Commit

Permalink
Remove documentation sections covered on the website
Browse files Browse the repository at this point in the history
  • Loading branch information
acogoluegnes committed Sep 17, 2024
1 parent a968c69 commit e5d48ba
Showing 1 changed file with 0 additions and 78 deletions.
78 changes: 0 additions & 78 deletions src/docs/asciidoc/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,84 +26,6 @@ include::{test-examples}/Api.java[tag=connection-settings]
<1> Use the `guest` user by default
<2> Use the `admin` user for this connection

[[lifecycle-listeners]]
=== Lifecycle Listeners

It is possible to add one or several listeners when creating a `Connection` instance:

.Setting a listener on a connection
[source,java,indent=0]
--------
include::{test-examples}/Api.java[tag=listener-connection]
--------
<1> Setting a listener
<2> The previous state of the connection
<3> The current (new) state of the connection
<4> The cause of the failure (in case of failure)
<5> The connection instance (as a `Resource`)

It is also possible to set listeners on publisher instances:

.Setting a listener on a publisher
[source,java,indent=0]
--------
include::{test-examples}/Api.java[tag=listener-publisher]
--------
<1> Setting a listener

And on consumer instances as well:

.Setting a listener on a consumer
[source,java,indent=0]
--------
include::{test-examples}/Api.java[tag=listener-consumer]
--------
<1> Setting a listener

The listener API is the same for connection, publishers, and consumers.
They all implement the {javadoc-url}/com/rabbitmq/client/amqp/Resource.html[`Resource`] marker interface.
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.
See the snippet above for the information available in the `Context`.

A resource {javadoc-url}/com/rabbitmq/client/amqp/Resource.State.html[`State`] can have the following values: `OPENING`, `OPEN`, `RECOVERING`, `CLOSING`, `CLOSED`.

=== Recovery

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).
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.
Developers have less to worry about network stability and node restart, as the client will take care of it.

The client tries to reconnect every 5 seconds until it succeeds.
It is possible to change this behavior by providing a custom {javadoc-url}/com/rabbitmq/client/amqp/BackOffDelayPolicy.html[`BackOffDelayPolicy`]:

.Setting a back-off policy for connection recovery
[source,java,indent=0]
--------
include::{test-examples}/Api.java[tag=connection-recovery-back-off]
--------
<1> Configure recovery
<2> Set the back-off delay policy

It is also possible to deactivate topology recovery if it is not appropriate for a given application.
The application would usually register a connection <<lifecycle-listeners,lifecycle listener>> to know when the connection is recovered and recover its own state accordingly.

.Deactivating topology recovery
[source,java,indent=0]
--------
include::{test-examples}/Api.java[tag=connection-recovery-no-topology-recovery]
--------
<1> Deactivate topology recovery
<2> Restore application state when connection is recovered

It is also possible to deactivate recovery altogether:

.Deactivating recovery
[source,java,indent=0]
--------
include::{test-examples}/Api.java[tag=connection-recovery-deactivate]
--------
<1> Deactivate recovery

=== Metrics Collection

The library provides the {javadoc-url}/com/rabbitmq/client/amqp/metrics/MetricsCollector.html[`MetricsCollector`] abstraction to collect metrics.
Expand Down

0 comments on commit e5d48ba

Please sign in to comment.