activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eugene Rodos (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AMQ-2659) JMSException incorrectly thrown when using XAConnection/XASession outside a transaction
Date Tue, 20 Apr 2010 16:58:14 GMT

    [ 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.


Mime
View raw message