Package org.apache.qpid.protonj2.client
Class ReconnectOptions
- java.lang.Object
-
- org.apache.qpid.protonj2.client.ReconnectOptions
-
public class ReconnectOptions extends java.lang.ObjectOptions that control the reconnection behavior of a clientConnection.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_RECONNECT_DELAYstatic doubleDEFAULT_RECONNECT_BACKOFF_MULTIPLIERstatic intDEFAULT_RECONNECT_DELAYstatic booleanDEFAULT_RECONNECT_ENABLEDstatic booleanDEFAULT_USE_RECONNECT_BACKOFFstatic intDEFAULT_WARN_AFTER_RECONNECT_ATTEMPTSstatic intINFINITE
-
Constructor Summary
Constructors Constructor Description ReconnectOptions()Create a newReconnectOptionsinstance configured with default configuration settings.ReconnectOptions(ReconnectOptions options)Creates aReconnectOptionsinstance that is a copy of the given instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReconnectOptionsaddReconnectLocation(java.lang.String host, int port)Adds an additional reconnection location that can be used when attempting to reconnect the client following a connection failure.protected ReconnectOptionscopyInto(ReconnectOptions other)Copy all options from thisReconnectOptionsinstance into the instance provided.intmaxInitialConnectionAttempts()ReconnectOptionsmaxInitialConnectionAttempts(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()ReconnectOptionsmaxReconnectAttempts(int maxReconnectionAttempts)The number of reconnection attempts allowed before reporting the connection as failed to the client.intmaxReconnectDelay()ReconnectOptionsmaxReconnectDelay(int maxReconnectDelay)The maximum time that the client will wait before attempting a reconnect.doublereconnectBackOffMultiplier()ReconnectOptionsreconnectBackOffMultiplier(double reconnectBackOffMultiplier)The multiplier used to grow the reconnection delay value, defaults to 2.0d.intreconnectDelay()ReconnectOptionsreconnectDelay(int reconnectDelay)Controls the delay between successive reconnection attempts, defaults to 10 milliseconds.booleanreconnectEnabled()Returnstrueif reconnect is currently enabled for theConnectionthat these options are assigned to.ReconnectOptionsreconnectEnabled(boolean reconnectEnabled)java.util.List<ReconnectLocation>reconnectLocations()booleanuseReconnectBackOff()ReconnectOptionsuseReconnectBackOff(boolean useReconnectBackOff)Controls whether the time between reconnection attempts should grow based on a configured multiplier.intwarnAfterReconnectAttempts()ReconnectOptionswarnAfterReconnectAttempts(int warnAfterReconnectAttempts)Controls how often the client will log a message indicating that a reconnection is being attempted.
-
-
-
Field Detail
-
DEFAULT_RECONNECT_ENABLED
public static final boolean DEFAULT_RECONNECT_ENABLED
- See Also:
- Constant Field Values
-
INFINITE
public static final int INFINITE
- See Also:
- Constant Field Values
-
DEFAULT_WARN_AFTER_RECONNECT_ATTEMPTS
public static final int DEFAULT_WARN_AFTER_RECONNECT_ATTEMPTS
- See Also:
- Constant Field Values
-
DEFAULT_RECONNECT_DELAY
public static final int DEFAULT_RECONNECT_DELAY
- See Also:
- Constant Field Values
-
DEFAULT_MAX_RECONNECT_DELAY
public static final int DEFAULT_MAX_RECONNECT_DELAY
- See Also:
- Constant Field Values
-
DEFAULT_USE_RECONNECT_BACKOFF
public static final boolean DEFAULT_USE_RECONNECT_BACKOFF
- See Also:
- Constant Field Values
-
DEFAULT_RECONNECT_BACKOFF_MULTIPLIER
public static final double DEFAULT_RECONNECT_BACKOFF_MULTIPLIER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ReconnectOptions
public ReconnectOptions()
Create a newReconnectOptionsinstance configured with default configuration settings.
-
ReconnectOptions
public ReconnectOptions(ReconnectOptions options)
Creates aReconnectOptionsinstance that is a copy of the given instance.- Parameters:
options- TheReconnectOptionsinstance whose configuration should be copied to this one.
-
-
Method Detail
-
copyInto
protected ReconnectOptions copyInto(ReconnectOptions other)
Copy all options from thisReconnectOptionsinstance into the instance provided.- Parameters:
other- the target of this copy operation.- Returns:
- this
ReconnectOptionsinstance.
-
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
public ReconnectOptions reconnectEnabled(boolean 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
public ReconnectOptions addReconnectLocation(java.lang.String host, int port)
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
public java.util.List<ReconnectLocation> 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
public ReconnectOptions warnAfterReconnectAttempts(int 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
public ReconnectOptions 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. 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
public ReconnectOptions maxReconnectAttempts(int maxReconnectionAttempts)
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
public ReconnectOptions reconnectDelay(int 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
public ReconnectOptions maxReconnectDelay(int 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
public ReconnectOptions useReconnectBackOff(boolean 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
public ReconnectOptions reconnectBackOffMultiplier(double 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.
-
-