Class ActiveMQManagedConnection

java.lang.Object
org.apache.activemq.ra.ActiveMQManagedConnection
All Implemented Interfaces:
jakarta.jms.ExceptionListener, jakarta.resource.spi.ManagedConnection

public class ActiveMQManagedConnection extends Object implements jakarta.resource.spi.ManagedConnection, jakarta.jms.ExceptionListener
ActiveMQManagedConnection maps to real physical connection to the server. Since a ManagedConnection has to provide a transaction managment interface to the physical connection, and sessions are the objects implement transaction managment interfaces in the JMS API, this object also maps to a singe physical JMS session.

The side-effect is that JMS connection the application gets will allways create the same session object. This is good if running in an app server since the sessions are elisted in the context transaction. This is bad if used outside of an app server since the user may be trying to create 2 different sessions to coordinate 2 different uow.

  • Constructor Details

    • ActiveMQManagedConnection

      public ActiveMQManagedConnection(Subject subject, org.apache.activemq.ActiveMQConnection physicalConnection, ActiveMQConnectionRequestInfo info) throws jakarta.resource.ResourceException
      Throws:
      jakarta.resource.ResourceException
  • Method Details

    • isInManagedTx

      public boolean isInManagedTx()
    • matches

      public static boolean matches(Object x, Object y)
    • associate

      public void associate(Subject subject, ActiveMQConnectionRequestInfo info) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • getPhysicalConnection

      public jakarta.jms.Connection getPhysicalConnection()
    • getConnection

      public Object getConnection(Subject subject, jakarta.resource.spi.ConnectionRequestInfo info) throws jakarta.resource.ResourceException
      Specified by:
      getConnection in interface jakarta.resource.spi.ManagedConnection
      Throws:
      jakarta.resource.ResourceException
      See Also:
      • javax.resource.spi.ManagedConnection#getConnection(javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
    • destroy

      public void destroy() throws jakarta.resource.ResourceException
      Close down the physical connection to the server.
      Specified by:
      destroy in interface jakarta.resource.spi.ManagedConnection
      Throws:
      jakarta.resource.ResourceException
      See Also:
      • javax.resource.spi.ManagedConnection#destroy()
    • cleanup

      public void cleanup() throws jakarta.resource.ResourceException
      Cleans up all proxy handles attached to this physical connection so that they cannot be used anymore.
      Specified by:
      cleanup in interface jakarta.resource.spi.ManagedConnection
      Throws:
      jakarta.resource.ResourceException
      See Also:
      • javax.resource.spi.ManagedConnection#cleanup()
    • associateConnection

      public void associateConnection(Object connection) throws jakarta.resource.ResourceException
      Specified by:
      associateConnection in interface jakarta.resource.spi.ManagedConnection
      Throws:
      jakarta.resource.ResourceException
      See Also:
      • javax.resource.spi.ManagedConnection#associateConnection(java.lang.Object)
    • addConnectionEventListener

      public void addConnectionEventListener(jakarta.resource.spi.ConnectionEventListener listener)
      Specified by:
      addConnectionEventListener in interface jakarta.resource.spi.ManagedConnection
      See Also:
      • javax.resource.spi.ManagedConnection#addConnectionEventListener(javax.resource.spi.ConnectionEventListener)
    • removeConnectionEventListener

      public void removeConnectionEventListener(jakarta.resource.spi.ConnectionEventListener listener)
      Specified by:
      removeConnectionEventListener in interface jakarta.resource.spi.ManagedConnection
      See Also:
      • javax.resource.spi.ManagedConnection#removeConnectionEventListener(javax.resource.spi.ConnectionEventListener)
    • getXAResource

      public XAResource getXAResource() throws jakarta.resource.ResourceException
      Specified by:
      getXAResource in interface jakarta.resource.spi.ManagedConnection
      Throws:
      jakarta.resource.ResourceException
      See Also:
      • javax.resource.spi.ManagedConnection#getXAResource()
    • getLocalTransaction

      public jakarta.resource.spi.LocalTransaction getLocalTransaction() throws jakarta.resource.ResourceException
      Specified by:
      getLocalTransaction in interface jakarta.resource.spi.ManagedConnection
      Throws:
      jakarta.resource.ResourceException
      See Also:
      • javax.resource.spi.ManagedConnection#getLocalTransaction()
    • getMetaData

      public jakarta.resource.spi.ManagedConnectionMetaData getMetaData() throws jakarta.resource.ResourceException
      Specified by:
      getMetaData in interface jakarta.resource.spi.ManagedConnection
      Throws:
      jakarta.resource.ResourceException
      See Also:
      • javax.resource.spi.ManagedConnection#getMetaData()
    • setLogWriter

      public void setLogWriter(PrintWriter logWriter) throws jakarta.resource.ResourceException
      Specified by:
      setLogWriter in interface jakarta.resource.spi.ManagedConnection
      Throws:
      jakarta.resource.ResourceException
      See Also:
      • javax.resource.spi.ManagedConnection#setLogWriter(java.io.PrintWriter)
    • getLogWriter

      public PrintWriter getLogWriter() throws jakarta.resource.ResourceException
      Specified by:
      getLogWriter in interface jakarta.resource.spi.ManagedConnection
      Throws:
      jakarta.resource.ResourceException
      See Also:
      • javax.resource.spi.ManagedConnection#getLogWriter()
    • matches

      public boolean matches(Subject subject, jakarta.resource.spi.ConnectionRequestInfo info)
      Parameters:
      subject - subject to match
      info - cri to match
      Returns:
      whether the subject and cri match sufficiently to allow using this connection under the new circumstances
    • proxyClosedEvent

      public void proxyClosedEvent(ManagedConnectionProxy proxy)
      When a proxy is closed this cleans up the proxy and notifies the ConnectionEventListeners that a connection closed.
      Parameters:
      proxy -
    • onException

      public void onException(jakarta.jms.JMSException e)
      Specified by:
      onException in interface jakarta.jms.ExceptionListener
    • getTransactionContext

      public org.apache.activemq.TransactionContext getTransactionContext()
      Returns:
      Returns the transactionContext.
    • toString

      public String toString()
      Overrides:
      toString in class Object