Package org.apache.qpid.protonj2.client
Class ReconnectOptions
java.lang.Object
org.apache.qpid.protonj2.client.ReconnectOptions
- All Implemented Interfaces:
Cloneable
Options that control the reconnection behavior of a client
Connection
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final double
static final int
static final boolean
static final boolean
static final int
static final int
-
Constructor Summary
ConstructorDescriptionCreate a newReconnectOptions
instance configured with default configuration settings.ReconnectOptions
(ReconnectOptions options) Creates aReconnectOptions
instance that is a copy of the given instance. -
Method Summary
Modifier and TypeMethodDescriptionaddReconnectLocation
(String host, int port) Adds an additional reconnection location that can be used when attempting to reconnect the client following a connection failure.clone()
protected ReconnectOptions
copyInto
(ReconnectOptions other) Copy all options from thisReconnectOptions
instance into the instance provided.int
maxInitialConnectionAttempts
(int maxInitialConnectionAttempts) For a client that has never connected to a remote peer before this option controls how many attempts are made to connect before reporting the connection as failed.int
maxReconnectAttempts
(int maxReconnectionAttempts) The number of reconnection attempts allowed before reporting the connection as failed to the client.int
maxReconnectDelay
(int maxReconnectDelay) The maximum time that the client will wait before attempting a reconnect.double
reconnectBackOffMultiplier
(double reconnectBackOffMultiplier) The multiplier used to grow the reconnection delay value, defaults to 2.0d.int
reconnectDelay
(int reconnectDelay) Controls the delay between successive reconnection attempts, defaults to 10 milliseconds.boolean
Returnstrue
if reconnect is currently enabled for theConnection
that these options are assigned to.reconnectEnabled
(boolean reconnectEnabled) boolean
useReconnectBackOff
(boolean useReconnectBackOff) Controls whether the time between reconnection attempts should grow based on a configured multiplier.int
warnAfterReconnectAttempts
(int warnAfterReconnectAttempts) Controls how often the client will log a message indicating that a reconnection is being attempted.
-
Field Details
-
DEFAULT_RECONNECT_ENABLED
public static final boolean DEFAULT_RECONNECT_ENABLED- See Also:
-
INFINITE
public static final int INFINITE- See Also:
-
DEFAULT_WARN_AFTER_RECONNECT_ATTEMPTS
public static final int DEFAULT_WARN_AFTER_RECONNECT_ATTEMPTS- See Also:
-
DEFAULT_RECONNECT_DELAY
public static final int DEFAULT_RECONNECT_DELAY- See Also:
-
DEFAULT_MAX_RECONNECT_DELAY
public static final int DEFAULT_MAX_RECONNECT_DELAY- See Also:
-
DEFAULT_USE_RECONNECT_BACKOFF
public static final boolean DEFAULT_USE_RECONNECT_BACKOFF- See Also:
-
DEFAULT_RECONNECT_BACKOFF_MULTIPLIER
public static final double DEFAULT_RECONNECT_BACKOFF_MULTIPLIER- See Also:
-
-
Constructor Details
-
ReconnectOptions
public ReconnectOptions()Create a newReconnectOptions
instance configured with default configuration settings. -
ReconnectOptions
Creates aReconnectOptions
instance that is a copy of the given instance.- Parameters:
options
- TheReconnectOptions
instance whose configuration should be copied to this one.
-
-
Method Details
-
clone
-
copyInto
Copy all options from thisReconnectOptions
instance into the instance provided.- Parameters:
other
- the target of this copy operation.- Returns:
- the
ReconnectOptions
instance that was given.
-
reconnectEnabled
public boolean reconnectEnabled()Returnstrue
if reconnect is currently enabled for theConnection
that these options are assigned to.- Returns:
- the reconnect enabled configuration state for this options instance.
-
reconnectEnabled
Set totrue
to enable reconnection support on the associatedConnection
orfalse
to disable. When enabled aConnection
will attempt to reconnect to a remote based on the configuration set in this options instance.- Parameters:
reconnectEnabled
- Controls if reconnection is enabled or not for the associatedConnection
.- Returns:
- this
ReconnectOptions
instance.
-
addReconnectLocation
Adds an additional reconnection location that can be used when attempting to reconnect the client following a connection failure.- Parameters:
host
- The host name of the remote host to attempt a reconnection to.port
- The port on the remote host to use when connecting.- Returns:
- this
ReconnectOptions
instance.
-
reconnectLocations
- Returns:
- an unmodifiable view of the configured reconnect locations.
-
warnAfterReconnectAttempts
public int warnAfterReconnectAttempts()- Returns:
- the number of reconnection attempt before the client should log a warning.
-
warnAfterReconnectAttempts
Controls how often the client will log a message indicating that a reconnection is being attempted. The default is to log every 10 connection attempts.- Parameters:
warnAfterReconnectAttempts
- The number of attempts before logging an update about not yet reconnecting.- Returns:
- this
ReconnectOptions
instance.
-
maxInitialConnectionAttempts
public int maxInitialConnectionAttempts()- Returns:
- the configured maximum number of initial connection attempts to try before giving up
-
maxInitialConnectionAttempts
For a client that has never connected to a remote peer before this option controls how many attempts are made to connect before reporting the connection as failed. The default behavior is to use the value of maxReconnectAttempts.- Parameters:
maxInitialConnectionAttempts
- the maximum number of initial connection attempts to try before giving up.- Returns:
- this
ReconnectOptions
instance.
-
maxReconnectAttempts
public int maxReconnectAttempts()- Returns:
- the configured maximum number of reconnection attempts to try before giving up
-
maxReconnectAttempts
The number of reconnection attempts allowed before reporting the connection as failed to the client. The default is no limit or (-1).- Parameters:
maxReconnectionAttempts
- the maximum number of reconnection attempts to try before giving up.- Returns:
- this
ReconnectOptions
instance.
-
reconnectDelay
public int reconnectDelay()- Returns:
- the configured reconnect delay to use after between attempts to connect or reconnect.
-
reconnectDelay
Controls the delay between successive reconnection attempts, defaults to 10 milliseconds. If the back off option is not enabled this value remains constant.- Parameters:
reconnectDelay
- The reconnect delay to apply to successive attempts to reconnect.- Returns:
- this
ReconnectOptions
instance.
-
maxReconnectDelay
public int maxReconnectDelay()- Returns:
- the configured maximum reconnect attempt delay allowed when using delay back off scheduling.
-
maxReconnectDelay
The maximum time that the client will wait before attempting a reconnect. This value is only used when the back off feature is enabled to ensure that the delay does not grow too large. Defaults to 30 seconds as the max time between successive connection attempts.- Parameters:
maxReconnectDelay
- The maximum interval allowed when connection attempt back off is in effect.- Returns:
- this
ReconnectOptions
instance.
-
useReconnectBackOff
public boolean useReconnectBackOff()- Returns:
- if the reconnection attempts will be delayed using a back off multiplier.
-
useReconnectBackOff
Controls whether the time between reconnection attempts should grow based on a configured multiplier. This option defaults to true.- Parameters:
useReconnectBackOff
- should connection attempts use a back off of the configured delay.- Returns:
- this
ReconnectOptions
instance.
-
reconnectBackOffMultiplier
public double reconnectBackOffMultiplier()- Returns:
- the multiplier used when the reconnection back off feature is enabled.
-
reconnectBackOffMultiplier
The multiplier used to grow the reconnection delay value, defaults to 2.0d.- Parameters:
reconnectBackOffMultiplier
- the delay multiplier used when building delay between reconnection attempts.- Returns:
- this
ReconnectOptions
instance.
-