Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-2659

JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.3.0
    • 5.4.0, 5.16.0
    • Broker
    • None

    Description

      Currently, if one attempts to use an XAConnection (implemented by ActiveMQXAConnection) and consequently an XASession (implemented by ActiveMQXASession) outside a transaction, a JMSException is thrown. However, nowhere in the JMS Spec does it say that if an XAConnection/XASession is used, it must be enlisted in a transaction. It is perfectly legal to not start a transaction but still use the XA objects.

      I propose that the following 2 methods in ActiveMQXASession be changed as follows to resolve this bug:

          public boolean getTransacted() throws JMSException {
              return getTransactionContext().isInXATransaction();
          }
      
          /**
           * This is called before transacted work is done by the session.
           * XA transactions are controlled outside of the session so
           * nothing has to be done here.  The only reason for this method
           * to be here is to override the parent.
           */
          protected void doStartTransaction() {
          }
      


      The current version of these methods is as follows (for reference):

          public boolean getTransacted() throws JMSException {
              return true;
          }
      
          /**
           * This is called before transacted work is done by
           * the session.  XA Work can only be done when this
           * XA resource is associated with an Xid.
           *
           * @throws JMSException not associated with an Xid
           */
          protected void doStartTransaction() throws JMSException {
      
              if (!getTransactionContext().isInXATransaction()) {
                  throw new JMSException("Session's XAResource has not been enlisted in a distributed transaction.");
              }
      
          }
      

      Attachments

        1. JmsTestSupportXA.java
          6 kB
          Eugene Rodos
        2. JMSConsumerTestXA.java
          38 kB
          Eugene Rodos

        Issue Links

          Activity

            People

              gtully Gary Tully
              rodos77 Eugene Rodos
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: