1- get a message from *request* JMS queue.
2- validate the message if validation past move to step 3 if not move the message to *bad-request* queue and go to step 4.
3-save the message in database. if not successful move the message to *bad-request* queue and go to next step.
4-create responce and send it to *response* queue.
*A new transaction will start at step 1 which will commit/rollback at step 4.
*each JMS or database operation will be done in nested transaction.
Does BTM support nested transactions? I'm getting a "NestedTransactionNotSupportedException" from Spring and wasn't sure if the problem is from my configuration or TM.
"Your application cannot, however, both send a JMS message and receive a reply to it within the same transaction; the restriction described in Section 5.2.2, "Using JMS API Local Transactions," still applies."
Ludovic Orban wrote
All that can be done within a single XA transaction. Simply start your transaction, go to step #1 then commit after step #4.
At step #2, if validation fails you just send your message to bad-requests queue.
At step #3, if you get a SQLException send your message to bad-requests queue.
The TM will take care of committing messages sent to response-queue, bad-requests (if a message was sent) and the database (if something was written).
I don't see any value nested transactions would add here.
The Sun documentation is right although a bit unclear.
This is how it should have been written to make it more understandable:
Your application cannot, however, both send a JMS message and receive a reply to it (it == the message you just sent) within the same transaction.
The use case you described is not impacted by this statement so you can implement it - for instance - the way I described it. It is a very common pattern to received a message, update a DB then send a message in a single transaction and often the reason #1 to use JTA. Feel safe about it.