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 JmsConnection
JmsConnection 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 void
addConnection(JmsConnection c)
void
closeConnection()
Close the underlying connection.java.lang.String
configuredClientId()
The client id.java.lang.String
configuredPassword()
The password.java.lang.String
configuredUserName()
The username.VendorImplementation
configuredVendorImplementation()
The vendor specific implementation.boolean
connectionEquals(JmsConnection connection)
protected void
createConnection(javax.jms.ConnectionFactory factory)
javax.jms.Session
createSession(boolean transacted, int acknowledgeMode)
Creates a newSession
on the underlying JMSConnection
.javax.jms.Connection
currentConnection()
java.util.List<JmsConnection>
getConnections()
java.lang.Boolean
getRegisterOwner()
protected void
initConnection()
Initialise the underlying connection.javax.jms.ConnectionFactory
obtainConnectionFactory()
protected void
prepareConnection()
void
setConnections(java.util.List<JmsConnection> l)
void
setRegisterOwner(java.lang.Boolean b)
Specify whether to register this instance or its owner with the underlying connectionprotected void
startConnection()
Start the underlying connection.protected void
stopConnection()
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 CoreException
Description copied from class:AdaptrisConnectionImp
Initialise the underlying connection.- Overrides:
initConnection
in classJmsConnection
- Throws:
CoreException
- wrapping any exception.- See Also:
AdaptrisConnectionImp.init()
-
startConnection
protected void startConnection() throws CoreException
Description copied from class:AdaptrisConnectionImp
Start the underlying connection.- Overrides:
startConnection
in classJmsConnection
- Throws:
CoreException
- wrapping any exception.- See Also:
JmsConnection.startConnection()
-
stopConnection
protected void stopConnection()
Description copied from class:AdaptrisConnectionImp
Stop the underlying connection.- Overrides:
stopConnection
in classJmsConnection
- See Also:
JmsConnection.stopConnection()
-
closeConnection
public void closeConnection()
Description copied from class:AdaptrisConnectionImp
Close the underlying connection.- Overrides:
closeConnection
in classJmsConnection
- See Also:
JmsConnection.closeConnection()
-
createSession
public javax.jms.Session createSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
Creates a new
Session
on the underlying JMSConnection
.- Overrides:
createSession
in 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:
createConnection
in 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:
prepareConnection
in classJmsConnection
- Throws:
CoreException
-
obtainConnectionFactory
public javax.jms.ConnectionFactory obtainConnectionFactory() throws java.lang.Exception
- Overrides:
obtainConnectionFactory
in classJmsConnection
- Throws:
java.lang.Exception
-
currentConnection
public javax.jms.Connection currentConnection()
- Overrides:
currentConnection
in classJmsConnection
-
configuredClientId
public java.lang.String configuredClientId()
Description copied from interface:JmsConnectionConfig
The client id.- Specified by:
configuredClientId
in interfaceJmsConnectionConfig
- Overrides:
configuredClientId
in classJmsConnection
- Returns:
- the client id
-
configuredPassword
public java.lang.String configuredPassword()
Description copied from interface:JmsConnectionConfig
The password.- Specified by:
configuredPassword
in interfaceJmsConnectionConfig
- Overrides:
configuredPassword
in classJmsConnection
- Returns:
- the password
-
configuredUserName
public java.lang.String configuredUserName()
Description copied from interface:JmsConnectionConfig
The username.- Specified by:
configuredUserName
in interfaceJmsConnectionConfig
- Overrides:
configuredUserName
in classJmsConnection
- Returns:
- the username
-
configuredVendorImplementation
public VendorImplementation configuredVendorImplementation()
Description copied from interface:JmsConnectionConfig
The vendor specific implementation.- Specified by:
configuredVendorImplementation
in interfaceJmsConnectionConfig
- Overrides:
configuredVendorImplementation
in classJmsConnection
- Returns:
- the vendor specific implementation
-
connectionEquals
public boolean connectionEquals(JmsConnection connection)
- Specified by:
connectionEquals
in interfaceConnectionComparator<JmsConnection>
- Overrides:
connectionEquals
in classJmsConnection
-
-