FileDocCategorySizeDatePackage
JMSConnector.javaAPI DocApache Axis 1.434638Sat Apr 22 18:57:28 BST 2006org.apache.axis.transport.jms

JMSConnector

public 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.
author
Jaime Meritt (jmeritt@sonicsoftware.com)
author
Richard Chung (rchung@sonicsoftware.com)
author
Dave Chappell (chappell@sonicsoftware.com)
author
Ray Chun (rchun@sonicsoftware.com)

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$AsyncConnectioncreateAsyncConnection(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.ConnectioncreateConnectionWithRetry(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 JMSEndpointcreateEndpoint(java.lang.String destinationName)

public abstract JMSEndpointcreateEndpoint(javax.jms.Destination destination)

protected abstract org.apache.axis.transport.jms.JMSConnector$SyncConnectioncreateSyncConnection(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.StringgetClientID()

        return getSendConnection().getClientID();
    
public javax.jms.ConnectionFactorygetConnectionFactory()

        // there is always a send connection
        return getSendConnection().getConnectionFactory();
    
public JMSURLHelpergetJMSURL()

        return m_jmsurl;
    
public intgetNumRetries()

        return m_numRetries;
    
public java.lang.StringgetPassword()

        return getSendConnection().getPassword();
    
org.apache.axis.transport.jms.JMSConnector$AsyncConnectiongetReceiveConnection()

        return m_receiveConnection;
    
org.apache.axis.transport.jms.JMSConnector$SyncConnectiongetSendConnection()

        return m_sendConnection;
    
public java.lang.StringgetUsername()

        return getSendConnection().getUsername();
    
public org.apache.axis.components.jms.JMSVendorAdaptergetVendorAdapter()

        return m_adapter;
    
protected abstract javax.jms.ConnectioninternalConnect(javax.jms.ConnectionFactory connectionFactory, java.lang.String username, java.lang.String password)

public intnumSessions()

        return m_numSessions;
    
public voidshutdown()

        m_sendConnection.shutdown();
        if(m_allowReceive)
            m_receiveConnection.shutdown();
    
public voidstart()

        m_sendConnection.startConnection();
        if(m_allowReceive)
            m_receiveConnection.startConnection();

        JMSConnectorManager.getInstance().addConnectorToPool(this);
    
public voidstop()

        JMSConnectorManager.getInstance().removeConnectorFromPool(this);

        m_sendConnection.stopConnection();
        if(m_allowReceive)
            m_receiveConnection.stopConnection();