Class FailoverJmsConnection
- java.lang.Object
-
- com.adaptris.core.AdaptrisConnectionImp
-
- com.adaptris.core.AllowsRetriesConnection
-
- com.adaptris.core.jms.JmsConnection
-
- com.adaptris.core.jms.FailoverJmsConnection
-
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisConnection,ComponentLifecycle,ComponentLifecycleExtension,ConnectionComparator<JmsConnection>,JmsConnectionConfig,StateManagedComponent
@ComponentProfile(summary="Connect to a JMS 1.1 broker supporting broker failover in a vendor independent way", tag="connections,jms") public class FailoverJmsConnection extends JmsConnectionJmsConnection implementation that wraps a list of concrete JMSConnection instances to provide failover.This class is designed for use with JMS Brokers that do not provide any transparent failover facility. For instance, SonicMQ provides transparent failover, so you should use that instead rather than having another concrete JMSConnection instance.
Note the while this JmsConnection implementation still exposes connection configuration, these will be ignored, as all connection based activity is delegated to the underlying JmsConnections. The only configuration that overrides the underlying JmsConnection configuration is the connection-attempts and connection-wait.
In the adapter configuration file this class is aliased as failover-jms-connection which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.jms.JmsConnection
connection
-
Fields inherited from class com.adaptris.core.AdaptrisConnectionImp
log
-
-
Constructor Summary
Constructors Constructor Description FailoverJmsConnection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnection(JmsConnection c)voidcloseConnection()Close the underlying connection.java.lang.StringconfiguredClientId()The client id.java.lang.StringconfiguredPassword()The password.java.lang.StringconfiguredUserName()The username.VendorImplementationconfiguredVendorImplementation()The vendor specific implementation.booleanconnectionEquals(JmsConnection connection)protected voidcreateConnection(javax.jms.ConnectionFactory factory)javax.jms.SessioncreateSession(boolean transacted, int acknowledgeMode)Creates a newSessionon the underlying JMSConnection.javax.jms.ConnectioncurrentConnection()java.util.List<JmsConnection>getConnections()java.lang.BooleangetRegisterOwner()protected voidinitConnection()Initialise the underlying connection.javax.jms.ConnectionFactoryobtainConnectionFactory()protected voidprepareConnection()voidsetConnections(java.util.List<JmsConnection> l)voidsetRegisterOwner(java.lang.Boolean b)Specify whether to register this instance or its owner with the underlying connectionprotected voidstartConnection()Start the underlying connection.protected voidstopConnection()Stop the underlying connection.-
Methods inherited from class com.adaptris.core.jms.JmsConnection
additionalDebug, brokerDetailsForLogging, cloneForTesting, connectionErrorHandler, getAdditionalDebug, getClientId, getPassword, getUserName, getVendorImplementation, setAdditionalDebug, setClientId, setPassword, setUserName, setVendorImplementation
-
Methods inherited from class com.adaptris.core.AllowsRetriesConnection
connectionAttempts, connectionRetryInterval, createLoggingStatement, getConnectionAttempts, getConnectionRetryInterval, logWarning, setConnectionAttempts, setConnectionRetryInterval
-
Methods inherited from class com.adaptris.core.AdaptrisConnectionImp
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, close, getConnectionErrorHandler, getUniqueId, getWorkersFirstOnShutdown, init, prepare, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setUniqueId, setWorkersFirstOnShutdown, start, stop, workersFirstOnShutdown
-
-
-
-
Method Detail
-
initConnection
protected void initConnection() throws CoreExceptionDescription copied from class:AdaptrisConnectionImpInitialise the underlying connection.- Overrides:
initConnectionin classJmsConnection- Throws:
CoreException- wrapping any exception.- See Also:
AdaptrisConnectionImp.init()
-
startConnection
protected void startConnection() throws CoreExceptionDescription copied from class:AdaptrisConnectionImpStart the underlying connection.- Overrides:
startConnectionin classJmsConnection- Throws:
CoreException- wrapping any exception.- See Also:
JmsConnection.startConnection()
-
stopConnection
protected void stopConnection()
Description copied from class:AdaptrisConnectionImpStop the underlying connection.- Overrides:
stopConnectionin classJmsConnection- See Also:
JmsConnection.stopConnection()
-
closeConnection
public void closeConnection()
Description copied from class:AdaptrisConnectionImpClose the underlying connection.- Overrides:
closeConnectionin classJmsConnection- See Also:
JmsConnection.closeConnection()
-
createSession
public javax.jms.Session createSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSExceptionCreates a new
Sessionon the underlying JMSConnection.- Overrides:
createSessionin classJmsConnection- Parameters:
transacted- true if transactedacknowledgeMode- acknowledge mode- Returns:
- a new
Session - Throws:
javax.jms.JMSException- if any occurs
-
createConnection
protected void createConnection(javax.jms.ConnectionFactory factory) throws java.lang.Exception- Overrides:
createConnectionin classJmsConnection- Throws:
java.lang.Exception
-
getConnections
public java.util.List<JmsConnection> getConnections()
-
addConnection
public void addConnection(JmsConnection c)
-
setConnections
public void setConnections(java.util.List<JmsConnection> l)
-
getRegisterOwner
public java.lang.Boolean getRegisterOwner()
- Returns:
- the registerOwner
- See Also:
setRegisterOwner(Boolean)
-
setRegisterOwner
public void setRegisterOwner(java.lang.Boolean b)
Specify whether to register this instance or its owner with the underlying connection- Parameters:
b- the registerOwner to set, defaults to false which registers this instance as the owner of the underlying connection.
-
prepareConnection
protected void prepareConnection() throws CoreException- Overrides:
prepareConnectionin classJmsConnection- Throws:
CoreException
-
obtainConnectionFactory
public javax.jms.ConnectionFactory obtainConnectionFactory() throws java.lang.Exception- Overrides:
obtainConnectionFactoryin classJmsConnection- Throws:
java.lang.Exception
-
currentConnection
public javax.jms.Connection currentConnection()
- Overrides:
currentConnectionin classJmsConnection
-
configuredClientId
public java.lang.String configuredClientId()
Description copied from interface:JmsConnectionConfigThe client id.- Specified by:
configuredClientIdin interfaceJmsConnectionConfig- Overrides:
configuredClientIdin classJmsConnection- Returns:
- the client id
-
configuredPassword
public java.lang.String configuredPassword()
Description copied from interface:JmsConnectionConfigThe password.- Specified by:
configuredPasswordin interfaceJmsConnectionConfig- Overrides:
configuredPasswordin classJmsConnection- Returns:
- the password
-
configuredUserName
public java.lang.String configuredUserName()
Description copied from interface:JmsConnectionConfigThe username.- Specified by:
configuredUserNamein interfaceJmsConnectionConfig- Overrides:
configuredUserNamein classJmsConnection- Returns:
- the username
-
configuredVendorImplementation
public VendorImplementation configuredVendorImplementation()
Description copied from interface:JmsConnectionConfigThe vendor specific implementation.- Specified by:
configuredVendorImplementationin interfaceJmsConnectionConfig- Overrides:
configuredVendorImplementationin classJmsConnection- Returns:
- the vendor specific implementation
-
connectionEquals
public boolean connectionEquals(JmsConnection connection)
- Specified by:
connectionEqualsin interfaceConnectionComparator<JmsConnection>- Overrides:
connectionEqualsin classJmsConnection
-
-