Package org.apache.qpid.protonj2.client
Class ReconnectOptions
- java.lang.Object
-
- org.apache.qpid.protonj2.client.ReconnectOptions
-
- All Implemented Interfaces:
java.lang.Cloneable
public class ReconnectOptions extends java.lang.Object implements java.lang.Cloneable
Options that control the reconnection behavior of a clientConnection
.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_RECONNECT_DELAY
static double
DEFAULT_RECONNECT_BACKOFF_MULTIPLIER
static int
DEFAULT_RECONNECT_DELAY
static boolean
DEFAULT_RECONNECT_ENABLED
static boolean
DEFAULT_USE_RECONNECT_BACKOFF
static int
DEFAULT_WARN_AFTER_RECONNECT_ATTEMPTS
static int
INFINITE
-
Constructor Summary
Constructors Constructor Description ReconnectOptions()
Create a newReconnectOptions
instance configured with default configuration settings.ReconnectOptions(ReconnectOptions options)
Creates aReconnectOptions
instance that is a copy of the given instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.ReconnectOptions
clone()
protected ReconnectOptions
copyInto(ReconnectOptions other)
Copy all options from thisReconnectOptions
instance into the instance provided.int
maxInitialConnectionAttempts()
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.int
maxReconnectAttempts()
ReconnectOptions
maxReconnectAttempts(int maxReconnectionAttempts)
The number of reconnection attempts allowed before reporting the connection as failed to the client.int
maxReconnectDelay()
ReconnectOptions
maxReconnectDelay(int maxReconnectDelay)
The maximum time that the client will wait before attempting a reconnect.double
reconnectBackOffMultiplier()
ReconnectOptions
reconnectBackOffMultiplier(double reconnectBackOffMultiplier)
The multiplier used to grow the reconnection delay value, defaults to 2.0d.int
reconnectDelay()
ReconnectOptions
reconnectDelay(int reconnectDelay)
Controls the delay between successive reconnection attempts, defaults to 10 milliseconds.boolean
reconnectEnabled()
Returnstrue
if reconnect is currently enabled for theConnection
that these options are assigned to.ReconnectOptions
reconnectEnabled(boolean reconnectEnabled)
java.util.List<ReconnectLocation>
reconnectLocations()
boolean
useReconnectBackOff()
ReconnectOptions
useReconnectBackOff(boolean useReconnectBackOff)
Controls whether the time between reconnection attempts should grow based on a configured multiplier.int
warnAfterReconnectAttempts()
ReconnectOptions
warnAfterReconnectAttempts(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 newReconnectOptions
instance configured with default configuration settings.
-
ReconnectOptions
public ReconnectOptions(ReconnectOptions options)
Creates aReconnectOptions
instance that is a copy of the given instance.- Parameters:
options
- TheReconnectOptions
instance whose configuration should be copied to this one.
-
-
Method Detail
-
clone
public ReconnectOptions clone()
- Overrides:
clone
in classjava.lang.Object
-
copyInto
protected ReconnectOptions copyInto(ReconnectOptions other)
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
public ReconnectOptions reconnectEnabled(boolean 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
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
ReconnectOptions
instance.
-
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
ReconnectOptions
instance.
-
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
ReconnectOptions
instance.
-
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
ReconnectOptions
instance.
-
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
ReconnectOptions
instance.
-
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
ReconnectOptions
instance.
-
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
ReconnectOptions
instance.
-
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
ReconnectOptions
instance.
-
-