Here is what I want to do:
In my JMS listener, I want to have a(n inner) transaction that performs work, and that may end with an exception and be rolled back. Depending on the type of exception that caused the (inner) tx to roll back, I either want redelivery or ack the message as having been received properly.

I tried implementing this with a JTA aware ActiveMQ listener (XaPooledConnectionFactory), an inner transaction with propagation REQUIRES_NEW, and the listener catching exceptions and either (re)throwing RuntimeException to cause redelivery or return to cause ack. As of parallell thread it turned out there was a bug with JTA tx suspend/resume in ActiveMQ (https://issues.apache.org/jira/browse/AMQ-3059).

My question is what the most proper solution would be instead? I'm a JMS newbie, but AFAI can see I have at least two options: 1: Use transactional but non-XA listener and still throw RuntimeException for redelivery 2: Instead of throwing a RuntimeException to request redelivery, implement listener to explicitly request redelivery from the JMS session

Do I have more options?
I haven't tested if option 2 works with XA and suspend/resume; does anyone know? Or should I simply use a non-transactional listener...? (Would that be better than option 1?)

Thanks in advance,

 </Mattias>

Reply via email to