activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martyn Taylor <mtay...@redhat.com>
Subject Re: JTA Transaction in a MessageListener
Date Thu, 05 May 2016 14:22:42 GMT
Hi Alexis,

The onMessage() method (when invoked outside of an container) would be
called outside the boundaries of a transaction.  I see you are using
XASession in the test you provided.  When onMessage() is called, and a
message consumed, with an XASession, it would be done so with an ack mode
equal to XA in the session, but with no XA transaction started. This means
the consumed message is essentially orphaned (not associated with any
transaction).  The JMS spec does not state what to do in this case as this
shouldn't really happen, the XASession should only ever be used within the
context of a Tx.  If an orphaned message does happen, with Artemis
XASession, Artemis will associate the message with the next transaction.
This is a consequence of how we have optimised acking messages.  But would
likely behave differently with different providers.  As the spec isn't
specific.

I'm not sure what your use case is, but if you're trying to achieve MDB
like behaviour outside an application server.  It might be worth looking at
this:  http://activemq.apache.org/jca-container.html.

I hope this helps.

Regards
Martyn



On Wed, May 4, 2016 at 12:33 PM, Alexis Hassler <alexis.hassler@gmail.com>
wrote:

> Hi,
>
> Lately, I've sent a PR to the Narayana project in order to support JTA
> transactions in JMS MessageListener.
>
> In this PR, I started a JTA transaction in the onMessage method. The PR
> will be rejected because starting the transaction in the onMessage is too
> late : the message has already been dequeued.
>
> My problem is that the integration test (with artemis) passes, and I don't
> understand why.
>
> Can anyone explain me why it works, and how which test I can do to prove
> that the solution is not relevant ?
>
> Here is the PR : https://github.com/jbosstm/narayana/pull/1004
> And the MessageListener is here :
>
> https://github.com/hasalex/narayana/blob/master/ArjunaJTA/jms/src/main/java/org/jboss/narayana/jta/jms/MessageListenerProxy.java
>
> Thanks for your help,
>
> Alexis
> http://www.jtips.info, http://blog.alexis-hassler.com,
> http://www.mix-it.fr
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message