You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Eugene Rodos (JIRA)" <ji...@apache.org> on 2010/03/19 17:31:45 UTC

[jira] Created: (AMQ-2659) Incorrect Exception when using XAConnection/XASession outside a transaction

Incorrect Exception when using XAConnection/XASession outside a transaction
---------------------------------------------------------------------------

                 Key: AMQ-2659
                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
             Project: ActiveMQ
          Issue Type: Bug
    Affects Versions: 5.3.0
            Reporter: Eugene Rodos


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:
{noformat}
    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() {
    }
{noformat}
\\
The current version of these methods is as follows (for reference):

{noformat}
    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.");
        }

    }
{noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Eugene Rodos (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59134#action_59134 ] 

Eugene Rodos commented on AMQ-2659:
-----------------------------------

Isn't an ack sent at the end of ActiveMQSession.run() irrespective of whether there is a tx in progress or not?  line 885 in 5.3.1: asyncSendPacket(ack).  In fact, ActiveMQXASession doesn't override this so it will always execute the code in ActiveMQSession which surely can run without a tx.

I will work on a junit test shortly...

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Eugene Rodos (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58987#action_58987 ] 

Eugene Rodos commented on AMQ-2659:
-----------------------------------

The use case is that when the JMS client calls createConnection on the connection factory handle, an XA tx may have been started or may not have been.  The RA has no way of knowing this.  Therefore, we configure the RA to always use XAConnectionFactory.  This way, if a tx was started, the XA capabilities of the connection will be used, and if not, they won't, but it should work in either case.

Without this change, I get an Exception when trying to use the AMQXAConnFactory/AMQXAConn when a tx has not been started.  I've had to make this change to make our RA work with AMQ.  Other JMS engines (such as JBoss) don't have this restriction.  Nor do the JMS and JCA specify anywhere that if XA objects are used, a tx MUST be started.

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Tully updated AMQ-2659:
----------------------------

         Assignee: Gary Tully
    Fix Version/s: 5.4.0
      Component/s: Broker

will try and find some time for this before the 5.4 release

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>            Assignee: Gary Tully
>             Fix For: 5.4.0
>
>         Attachments: JMSConsumerTestXA.java, JmsTestSupportXA.java
>
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59135#action_59135 ] 

Gary Tully commented on AMQ-2659:
---------------------------------

yea, in the run() case it is. The issue is for other regular users of jms who swap in an XA connection factory for a regular connection factory and use an XASession as a regular session without a transaction, currently they will get an exception but with the proposed changes they will not and they are into undefined behavior.
The point being that this change has implications beyond the RA use case. A variant of the org.apache.activemq.JMSConsumerTest with an XA connection factory will demonstrate the problems that the current exception is trying to avoid. From a normal JMS user perspective, Session and XASession are not the same.

Maybe the way out of this is again through configuration, making the check for an active XA transaction optional, so it can be disabled for power users.


> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Tully resolved AMQ-2659.
-----------------------------

    Resolution: Fixed

changes implemented in r983057
thanks for the test case etc.

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>            Assignee: Gary Tully
>             Fix For: 5.4.0
>
>         Attachments: JMSConsumerTestXA.java, JmsTestSupportXA.java
>
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Eugene Rodos (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eugene Rodos updated AMQ-2659:
------------------------------

    Summary: JMSException incorrectly thrown when using XAConnection/XASession outside a transaction  (was: Incorrect Exception when using XAConnection/XASession outside a transaction)

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Eugene Rodos (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59136#action_59136 ] 

Eugene Rodos commented on AMQ-2659:
-----------------------------------

I still don't understand why using XASession without a tx is "undefined behavior".  No, they are not the same.  XASession has additional functionality but should still work as a regular session in the absence of tx. After all, XASession extends Session so even by the API an XASession can be treated as a regular Session.  In fact, the JMS client will always get a regular Session to work with.  However, the RA may instantiate an XASession behind the scenes.

If we make this change and modify JMSConsumerTest to use XASession, what problem are you expecting to occur?



> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Eugene Rodos (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eugene Rodos updated AMQ-2659:
------------------------------

    Attachment: JmsTestSupportXA.java
                JMSConsumerTestXA.java

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>         Attachments: JMSConsumerTestXA.java, JmsTestSupportXA.java
>
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Eugene Rodos (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59432#action_59432 ] 

Eugene Rodos commented on AMQ-2659:
-----------------------------------

Hi Gary,

Did you have a chance to run the attached test and check the additional proposed change?  Does it satisfy your concerns?  Can these changes be adopted?  I think in this case it is better to make it work for all use cases as opposed to going the config route.

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>         Attachments: JMSConsumerTestXA.java, JmsTestSupportXA.java
>
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Eugene Rodos (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59149#action_59149 ] 

Eugene Rodos commented on AMQ-2659:
-----------------------------------

Ok, so I modified JMSConsumerTest to use XASession (attached).  I did initially see some problems and now understand what you were talking about.  However, I was able to get rid of the problem and make the tests pass by including the following method in ActiveMQXASession: \\ \\
{noformat}
    public boolean isAutoAcknowledge() {
       return true;
    }
{noformat}

I think this makes sense since for an XASession transactions are controlled outside of the session and so as far as the session is concerned it is always AUTO_ACKNOWLEDGE.

This would take care of your concerns, no?

P.S.  There are 4 failures in the test but I think those are because the tests don't make sense any more with the transactions not controlled by the session.  Sorry, I don't have more time right now to look into it further.

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58986#action_58986 ] 

Gary Tully commented on AMQ-2659:
---------------------------------

what is your use case here? it is normal for an xa connection to be used with an xa transaction, that is what xa_rdonly is about. Not sure why the check was added in the first place but it has been around for quite a while and is a good indication of intent, as in, it helps determine whether an XA connection factory is being used as desired when it is configured with a transaction manager. I am slow to drop it without out good reason.

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59101#action_59101 ] 

Gary Tully commented on AMQ-2659:
---------------------------------

to speed up the process, it would help if there were a few unit tests that demonstrated the required behavior and don't break anything else. I think message receipt will be problematic as an XASession is always transacted w.r.t acks and without a transaction there will be no ack.

btw: I think the change to getTransacted() will help with https://issues.apache.org/activemq/browse/AMQ-2712 which is good.

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction

Posted by "Eugene Rodos (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59098#action_59098 ] 

Eugene Rodos commented on AMQ-2659:
-----------------------------------

So what's the verdict?  Can we get this change into 5.4.0 so I can use AMQ with our RA and not have to patch the source on my end?

> JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-2659
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2659
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Eugene Rodos
>
> 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:
> {noformat}
>     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() {
>     }
> {noformat}
> \\
> The current version of these methods is as follows (for reference):
> {noformat}
>     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.");
>         }
>     }
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.