Class ActiveMQXAResourceWrapper

  • All Implemented Interfaces:
    javax.transaction.xa.XAResource, org.apache.activemq.artemis.api.core.client.SessionFailureListener, org.apache.activemq.artemis.core.remoting.FailureListener

    public class ActiveMQXAResourceWrapper
    extends java.lang.Object
    implements javax.transaction.xa.XAResource, org.apache.activemq.artemis.api.core.client.SessionFailureListener
    XAResourceWrapper. Mainly from org.jboss.server.XAResourceWrapper from the JBoss AS server module The reason why we don't use that class directly is that it assumes on failure of connection the RM_FAIL or RM_ERR is thrown, but in ActiveMQ Artemis we throw XA_RETRY since we want the recovery manager to be able to retry on failure without having to manually retry
    • Field Summary

      • Fields inherited from interface javax.transaction.xa.XAResource

        TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void beforeReconnect​(org.apache.activemq.artemis.api.core.ActiveMQException me)  
      protected javax.transaction.xa.XAException check​(javax.transaction.xa.XAException e)
      Check whether an XAException is fatal.
      void close()
      Close the connection
      void commit​(javax.transaction.xa.Xid xid, boolean onePhase)  
      protected javax.transaction.xa.XAResource connect()
      Connect to the server if not already done so
      void connectionFailed​(org.apache.activemq.artemis.api.core.ActiveMQException me, boolean failedOver)  
      void connectionFailed​(org.apache.activemq.artemis.api.core.ActiveMQException me, boolean failedOver, java.lang.String scaleDownTargetNodeID)  
      void end​(javax.transaction.xa.Xid xid, int flags)  
      void forget​(javax.transaction.xa.Xid xid)  
      int getTransactionTimeout()  
      boolean isSameRM​(javax.transaction.xa.XAResource xaRes)  
      int prepare​(javax.transaction.xa.Xid xid)  
      javax.transaction.xa.Xid[] recover​(int flag)  
      void rollback​(javax.transaction.xa.Xid xid)  
      boolean setTransactionTimeout​(int seconds)  
      void start​(javax.transaction.xa.Xid xid, int flags)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • ActiveMQXAResourceWrapper

        public ActiveMQXAResourceWrapper​(XARecoveryConfig... xaRecoveryConfigs)
    • Method Detail

      • recover

        public javax.transaction.xa.Xid[] recover​(int flag)
                                           throws javax.transaction.xa.XAException
        Specified by:
        recover in interface javax.transaction.xa.XAResource
        Throws:
        javax.transaction.xa.XAException
      • commit

        public void commit​(javax.transaction.xa.Xid xid,
                           boolean onePhase)
                    throws javax.transaction.xa.XAException
        Specified by:
        commit in interface javax.transaction.xa.XAResource
        Throws:
        javax.transaction.xa.XAException
      • rollback

        public void rollback​(javax.transaction.xa.Xid xid)
                      throws javax.transaction.xa.XAException
        Specified by:
        rollback in interface javax.transaction.xa.XAResource
        Throws:
        javax.transaction.xa.XAException
      • forget

        public void forget​(javax.transaction.xa.Xid xid)
                    throws javax.transaction.xa.XAException
        Specified by:
        forget in interface javax.transaction.xa.XAResource
        Throws:
        javax.transaction.xa.XAException
      • isSameRM

        public boolean isSameRM​(javax.transaction.xa.XAResource xaRes)
                         throws javax.transaction.xa.XAException
        Specified by:
        isSameRM in interface javax.transaction.xa.XAResource
        Throws:
        javax.transaction.xa.XAException
      • prepare

        public int prepare​(javax.transaction.xa.Xid xid)
                    throws javax.transaction.xa.XAException
        Specified by:
        prepare in interface javax.transaction.xa.XAResource
        Throws:
        javax.transaction.xa.XAException
      • start

        public void start​(javax.transaction.xa.Xid xid,
                          int flags)
                   throws javax.transaction.xa.XAException
        Specified by:
        start in interface javax.transaction.xa.XAResource
        Throws:
        javax.transaction.xa.XAException
      • end

        public void end​(javax.transaction.xa.Xid xid,
                        int flags)
                 throws javax.transaction.xa.XAException
        Specified by:
        end in interface javax.transaction.xa.XAResource
        Throws:
        javax.transaction.xa.XAException
      • getTransactionTimeout

        public int getTransactionTimeout()
                                  throws javax.transaction.xa.XAException
        Specified by:
        getTransactionTimeout in interface javax.transaction.xa.XAResource
        Throws:
        javax.transaction.xa.XAException
      • setTransactionTimeout

        public boolean setTransactionTimeout​(int seconds)
                                      throws javax.transaction.xa.XAException
        Specified by:
        setTransactionTimeout in interface javax.transaction.xa.XAResource
        Throws:
        javax.transaction.xa.XAException
      • connectionFailed

        public void connectionFailed​(org.apache.activemq.artemis.api.core.ActiveMQException me,
                                     boolean failedOver)
        Specified by:
        connectionFailed in interface org.apache.activemq.artemis.core.remoting.FailureListener
      • connectionFailed

        public void connectionFailed​(org.apache.activemq.artemis.api.core.ActiveMQException me,
                                     boolean failedOver,
                                     java.lang.String scaleDownTargetNodeID)
        Specified by:
        connectionFailed in interface org.apache.activemq.artemis.core.remoting.FailureListener
      • beforeReconnect

        public void beforeReconnect​(org.apache.activemq.artemis.api.core.ActiveMQException me)
        Specified by:
        beforeReconnect in interface org.apache.activemq.artemis.api.core.client.SessionFailureListener
      • connect

        protected javax.transaction.xa.XAResource connect()
                                                   throws java.lang.Exception
        Connect to the server if not already done so
        Returns:
        the connectionFactory XAResource
        Throws:
        java.lang.Exception - for any problem
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • close

        public void close()
        Close the connection
      • check

        protected javax.transaction.xa.XAException check​(javax.transaction.xa.XAException e)
                                                  throws javax.transaction.xa.XAException
        Check whether an XAException is fatal. If it is an RM problem we close the connection so the next call will reconnect.
        Parameters:
        e - the xa exception
        Returns:
        never
        Throws:
        javax.transaction.xa.XAException - always