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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final doublestatic final intstatic final booleanstatic final booleanstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newReconnectOptionsinstance configured with default configuration settings.ReconnectOptions(ReconnectOptions options) Creates aReconnectOptionsinstance 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 ReconnectOptionscopyInto(ReconnectOptions other) Copy all options from thisReconnectOptionsinstance into the instance provided.intmaxInitialConnectionAttempts(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.intmaxReconnectAttempts(int maxReconnectionAttempts) The number of reconnection attempts allowed before reporting the connection as failed to the client.intmaxReconnectDelay(int maxReconnectDelay) The maximum time that the client will wait before attempting a reconnect.doublereconnectBackOffMultiplier(double reconnectBackOffMultiplier) The multiplier used to grow the reconnection delay value, defaults to 2.0d.intreconnectDelay(int reconnectDelay) Controls the delay between successive reconnection attempts, defaults to 10 milliseconds.booleanReturnstrueif reconnect is currently enabled for theConnectionthat these options are assigned to.reconnectEnabled(boolean reconnectEnabled) booleanuseReconnectBackOff(boolean useReconnectBackOff) Controls whether the time between reconnection attempts should grow based on a configured multiplier.intwarnAfterReconnectAttempts(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 newReconnectOptionsinstance configured with default configuration settings. -
ReconnectOptions
Creates aReconnectOptionsinstance that is a copy of the given instance.- Parameters:
options- TheReconnectOptionsinstance whose configuration should be copied to this one.
-
-
Method Details
-
clone
-
copyInto
Copy all options from thisReconnectOptionsinstance into the instance provided.- Parameters:
other- the target of this copy operation.- Returns:
- the
ReconnectOptionsinstance that was given.
-
reconnectEnabled
public boolean reconnectEnabled()Returnstrueif reconnect is currently enabled for theConnectionthat these options are assigned to.- Returns:
- the reconnect enabled configuration state for this options instance.
-
reconnectEnabled
Set totrueto enable reconnection support on the associatedConnectionorfalseto disable. When enabled aConnectionwill 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
ReconnectOptionsinstance.
-
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
ReconnectOptionsinstance.
-
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
ReconnectOptionsinstance.
-
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
ReconnectOptionsinstance.
-
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
ReconnectOptionsinstance.
-
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
ReconnectOptionsinstance.
-
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
ReconnectOptionsinstance.
-
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
ReconnectOptionsinstance.
-
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
ReconnectOptionsinstance.
-