I struggeling with JTA, two-phase-commit, JMS- and JDBC-transactions. The idea is (in short) to
- receive a message on a queue
- perform some database operations
- acknowledge the message, when the db operations have been successful
So I got the XAQueueConnectionFactory
, create the XAQueueSession
, create a receiver from the session and set a message listener.
Inside the listener, in the onMessage
method, I begin my user transaction, do the jdbc stuff and commit the transaction or do a rollback, if something went wrong. Now I expected (aka "hoped") that the message would be acknowledged, when the user transaction commits.
But that doesn't happen, the messages are still on the queue and get redelivered again and again.
What am I missing? I double-checked the session and the acknowledge mode really is "SESSION_TRANSACTED
" and getTransacted
returns true.
I don't have a Java EE container, no spring, no message driven beans. I use the standalone JTA bitronix.