JMSConnectorpublic abstract class JMSConnector extends Object JMSConnector is an abstract class that encapsulates the work of connecting
to JMS destinations. Its subclasses are TopicConnector and QueueConnector
which further specialize connections to the pub-sub and the ptp domains.
It also implements the capability to retry connections in the event of
failures. |
Fields Summary |
---|
protected int | m_numRetries | protected long | m_connectRetryInterval | protected long | m_interactRetryInterval | protected long | m_timeoutTime | protected long | m_poolTimeout | protected AsyncConnection | m_receiveConnection | protected SyncConnection | m_sendConnection | protected int | m_numSessions | protected boolean | m_allowReceive | protected org.apache.axis.components.jms.JMSVendorAdapter | m_adapter | protected JMSURLHelper | m_jmsurl |
Constructors Summary |
---|
public JMSConnector(javax.jms.ConnectionFactory connectionFactory, int numRetries, int numSessions, long connectRetryInterval, long interactRetryInterval, long timeoutTime, boolean allowReceive, String clientID, String username, String password, org.apache.axis.components.jms.JMSVendorAdapter adapter, JMSURLHelper jmsurl)
m_numRetries = numRetries;
m_connectRetryInterval = connectRetryInterval;
m_interactRetryInterval = interactRetryInterval;
m_timeoutTime = timeoutTime;
m_poolTimeout = timeoutTime/(long)numRetries;
m_numSessions = numSessions;
m_allowReceive = allowReceive;
m_adapter = adapter;
m_jmsurl = jmsurl;
// try to connect initially so we can fail fast
// in the case of irrecoverable errors.
// If we fail in a recoverable fashion we will retry
javax.jms.Connection sendConnection = createConnectionWithRetry(
connectionFactory,
username,
password);
m_sendConnection = createSyncConnection(connectionFactory, sendConnection,
m_numSessions, "SendThread",
clientID,
username,
password);
m_sendConnection.start();
if(m_allowReceive)
{
javax.jms.Connection receiveConnection = createConnectionWithRetry(
connectionFactory,
username,
password);
m_receiveConnection = createAsyncConnection(connectionFactory,
receiveConnection,
"ReceiveThread",
clientID,
username,
password);
m_receiveConnection.start();
}
|
Methods Summary |
---|
protected abstract org.apache.axis.transport.jms.JMSConnector$AsyncConnection | createAsyncConnection(javax.jms.ConnectionFactory factory, javax.jms.Connection connection, java.lang.String threadName, java.lang.String clientID, java.lang.String username, java.lang.String password)
| protected javax.jms.Connection | createConnectionWithRetry(javax.jms.ConnectionFactory connectionFactory, java.lang.String username, java.lang.String password)
javax.jms.Connection connection = null;
for(int numTries = 1; connection == null; numTries++)
{
try
{
connection = internalConnect(connectionFactory, username, password);
}
catch(JMSException jmse)
{
if(!m_adapter.isRecoverable(jmse, JMSVendorAdapter.CONNECT_ACTION) || numTries == m_numRetries)
throw jmse;
else
try{Thread.sleep(m_connectRetryInterval);}catch(InterruptedException ie){};
}
}
return connection;
| public abstract JMSEndpoint | createEndpoint(java.lang.String destinationName)
| public abstract JMSEndpoint | createEndpoint(javax.jms.Destination destination)
| protected abstract org.apache.axis.transport.jms.JMSConnector$SyncConnection | createSyncConnection(javax.jms.ConnectionFactory factory, javax.jms.Connection connection, int numSessions, java.lang.String threadName, java.lang.String clientID, java.lang.String username, java.lang.String password)
| public java.lang.String | getClientID()
return getSendConnection().getClientID();
| public javax.jms.ConnectionFactory | getConnectionFactory()
// there is always a send connection
return getSendConnection().getConnectionFactory();
| public JMSURLHelper | getJMSURL()
return m_jmsurl;
| public int | getNumRetries()
return m_numRetries;
| public java.lang.String | getPassword()
return getSendConnection().getPassword();
| org.apache.axis.transport.jms.JMSConnector$AsyncConnection | getReceiveConnection()
return m_receiveConnection;
| org.apache.axis.transport.jms.JMSConnector$SyncConnection | getSendConnection()
return m_sendConnection;
| public java.lang.String | getUsername()
return getSendConnection().getUsername();
| public org.apache.axis.components.jms.JMSVendorAdapter | getVendorAdapter()
return m_adapter;
| protected abstract javax.jms.Connection | internalConnect(javax.jms.ConnectionFactory connectionFactory, java.lang.String username, java.lang.String password)
| public int | numSessions()
return m_numSessions;
| public void | shutdown()
m_sendConnection.shutdown();
if(m_allowReceive)
m_receiveConnection.shutdown();
| public void | start()
m_sendConnection.startConnection();
if(m_allowReceive)
m_receiveConnection.startConnection();
JMSConnectorManager.getInstance().addConnectorToPool(this);
| public void | stop()
JMSConnectorManager.getInstance().removeConnectorFromPool(this);
m_sendConnection.stopConnection();
if(m_allowReceive)
m_receiveConnection.stopConnection();
|
|