Package com.adaptris.core
Class AllowsRetriesConnection
java.lang.Object
com.adaptris.core.AdaptrisConnectionImp
com.adaptris.core.AllowsRetriesConnection
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisConnection,ComponentLifecycle,ComponentLifecycleExtension,StateManagedComponent
- Direct Known Subclasses:
DatabaseConnection,JmsConnection,JmxConnection
Abstract class for connections that have the ability to retry connections.
Generally speaking for connections that physically require initialisation such as a connection to a JMS Broker or a Database, it should be possible to configure the connection to retry the connection if it initially fails. For other types of connection such as binding on a socket, this isn't so valid.
Previously AdaptrisConnectionImp exposed connectionAttemps and connectionWait however, this class was introduced reduce the number of un-used fields in the connection hierarchy.
- See Also:
-
Field Summary
Fields inherited from class com.adaptris.core.AdaptrisConnectionImp
log -
Constructor Summary
ConstructorsConstructorDescriptionDefault Constructor with the following default values. -
Method Summary
Modifier and TypeMethodDescriptionintlongReturns the wait between connection attempts in milliseconds.protected StringcreateLoggingStatement(int attempt) Returns the number of connection attempts to make.protected booleanlogWarning(int attemptCount) voidSets the number of connection attempts to make.voidsetConnectionRetryInterval(TimeInterval interval) Set the interval between each retry attempt.Methods inherited from class com.adaptris.core.AdaptrisConnectionImp
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, cloneForTesting, close, closeConnection, connectionErrorHandler, getConnectionErrorHandler, getUniqueId, getWorkersFirstOnShutdown, init, initConnection, prepare, prepareConnection, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setUniqueId, setWorkersFirstOnShutdown, start, startConnection, stop, stopConnection, workersFirstOnShutdown
-
Constructor Details
-
AllowsRetriesConnection
public AllowsRetriesConnection()Default Constructor with the following default values.- connectionAttempts is -1
- setConnectionWait is 60000
-
-
Method Details
-
setConnectionAttempts
Sets the number of connection attempts to make. -1 means keep trying indefinitely.
- Parameters:
i- the number of connection attempts to make
-
getConnectionAttempts
Returns the number of connection attempts to make.
- Returns:
- the number of connection attempts to make
-
connectionAttempts
public int connectionAttempts() -
connectionRetryInterval
public long connectionRetryInterval()Returns the wait between connection attempts in milliseconds.- Returns:
- the connection retry interval in ms.
-
logWarning
protected boolean logWarning(int attemptCount) -
createLoggingStatement
-
getConnectionRetryInterval
-
setConnectionRetryInterval
Set the interval between each retry attempt.- Parameters:
interval- the interval between each retry attempt.
-