Class ConnectionProxy

  • All Implemented Interfaces:
    java.lang.AutoCloseable, javax.jms.Connection

    public class ConnectionProxy
    extends java.lang.Object
    implements javax.jms.Connection
    Proxy connection to wrap around provided XAConnection.
    Author:
    Gytis Trikleris
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Simply close the proxied connection if there is no active transaction.
      javax.jms.ConnectionConsumer createConnectionConsumer​(javax.jms.Destination destination, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
      Delegate to xaConnection
      javax.jms.ConnectionConsumer createDurableConnectionConsumer​(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
      Delegate to xaConnection.
      javax.jms.Session createSession()  
      javax.jms.Session createSession​(boolean transacted, int acknowledgeMode)
      Simply create a session with an XA connection if there is no active transaction.
      javax.jms.Session createSession​(int sessionMode)  
      javax.jms.ConnectionConsumer createSharedConnectionConsumer​(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)  
      javax.jms.ConnectionConsumer createSharedDurableConnectionConsumer​(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)  
      java.lang.String getClientID()
      Delegate to xaConnection
      javax.jms.ExceptionListener getExceptionListener()
      Delegate to xaConnection
      javax.jms.ConnectionMetaData getMetaData()
      Delegate to xaConnection
      void setClientID​(java.lang.String clientID)  
      void setExceptionListener​(javax.jms.ExceptionListener listener)
      Delegate to xaConnection
      void start()
      Delegate to xaConnection
      void stop()
      Delegate to xaConnection
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConnectionProxy

        public ConnectionProxy​(javax.jms.XAConnection xaConnection,
                               TransactionHelper transactionHelper)
        Parameters:
        xaConnection - XA connection which needs to be proxied.
        transactionHelper - utility to make transaction resources registration easier.
    • Method Detail

      • createSession

        public javax.jms.Session createSession​(boolean transacted,
                                               int acknowledgeMode)
                                        throws javax.jms.JMSException
        Simply create a session with an XA connection if there is no active transaction. Or create a proxied session and register it with an active transaction.
        Specified by:
        createSession in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
        See Also:
        SessionProxy, Connection.createSession(boolean, int)
      • createSession

        public javax.jms.Session createSession​(int sessionMode)
                                        throws javax.jms.JMSException
        Specified by:
        createSession in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • createSession

        public javax.jms.Session createSession()
                                        throws javax.jms.JMSException
        Specified by:
        createSession in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • close

        public void close()
                   throws javax.jms.JMSException
        Simply close the proxied connection if there is no active transaction. Or register a ConnectionClosingSynchronization if active transaction exists.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException - if transaction service has failed (in unexpected way) to obtain transaction status, or if synchronization registration, or connection closing has failed.
      • getClientID

        public java.lang.String getClientID()
                                     throws javax.jms.JMSException
        Delegate to xaConnection
        Specified by:
        getClientID in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
        See Also:
        Connection.getClientID()
      • setClientID

        public void setClientID​(java.lang.String clientID)
                         throws javax.jms.JMSException
        Specified by:
        setClientID in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
        See Also:
        Connection.setClientID(String)
      • getMetaData

        public javax.jms.ConnectionMetaData getMetaData()
                                                 throws javax.jms.JMSException
        Delegate to xaConnection
        Specified by:
        getMetaData in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
        See Also:
        Connection.getMetaData()
      • getExceptionListener

        public javax.jms.ExceptionListener getExceptionListener()
                                                         throws javax.jms.JMSException
        Delegate to xaConnection
        Specified by:
        getExceptionListener in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
        See Also:
        Connection.getExceptionListener()
      • setExceptionListener

        public void setExceptionListener​(javax.jms.ExceptionListener listener)
                                  throws javax.jms.JMSException
        Delegate to xaConnection
        Specified by:
        setExceptionListener in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
        See Also:
        Connection.setExceptionListener(ExceptionListener)
      • start

        public void start()
                   throws javax.jms.JMSException
        Delegate to xaConnection
        Specified by:
        start in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
        See Also:
        Connection.start()
      • stop

        public void stop()
                  throws javax.jms.JMSException
        Delegate to xaConnection
        Specified by:
        stop in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
        See Also:
        Connection.stop()
      • createConnectionConsumer

        public javax.jms.ConnectionConsumer createConnectionConsumer​(javax.jms.Destination destination,
                                                                     java.lang.String messageSelector,
                                                                     javax.jms.ServerSessionPool sessionPool,
                                                                     int maxMessages)
                                                              throws javax.jms.JMSException
        Delegate to xaConnection
        Specified by:
        createConnectionConsumer in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
        See Also:
        Connection.createConnectionConsumer(Destination, String, ServerSessionPool, int)
      • createSharedConnectionConsumer

        public javax.jms.ConnectionConsumer createSharedConnectionConsumer​(javax.jms.Topic topic,
                                                                           java.lang.String subscriptionName,
                                                                           java.lang.String messageSelector,
                                                                           javax.jms.ServerSessionPool sessionPool,
                                                                           int maxMessages)
                                                                    throws javax.jms.JMSException
        Specified by:
        createSharedConnectionConsumer in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • createDurableConnectionConsumer

        public javax.jms.ConnectionConsumer createDurableConnectionConsumer​(javax.jms.Topic topic,
                                                                            java.lang.String subscriptionName,
                                                                            java.lang.String messageSelector,
                                                                            javax.jms.ServerSessionPool sessionPool,
                                                                            int maxMessages)
                                                                     throws javax.jms.JMSException
        Delegate to xaConnection.
        Specified by:
        createDurableConnectionConsumer in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
        See Also:
        Connection.createDurableConnectionConsumer(Topic, String, String, ServerSessionPool, int)
      • createSharedDurableConnectionConsumer

        public javax.jms.ConnectionConsumer createSharedDurableConnectionConsumer​(javax.jms.Topic topic,
                                                                                  java.lang.String subscriptionName,
                                                                                  java.lang.String messageSelector,
                                                                                  javax.jms.ServerSessionPool sessionPool,
                                                                                  int maxMessages)
                                                                           throws javax.jms.JMSException
        Specified by:
        createSharedDurableConnectionConsumer in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException