1

I have question on the order of committing in spring Transaction management. my current application requirement where i am using

and my transaction triggers from my MQ receive ...

Following is the order of action :

  1. MQ receives message
  2. DB insert in 3 tables - - procedure call
  3. DB insert in 3 tables - - procedure call
  4. DB insert in 3 tables - - procedure call
  5. MQ post message downstream queue
  6. MQ post message to 2nd down stream queue

I have tested all my rollback cases. a when step 6 fails it’s rolling back all the DB transaction including step 5 MQ rollback.

My question is once we post the message i would like to understand the commit order .. will it commit all the 3 DB transaction before the MQ commit to downstream queue ??

as I want to restrict the order of the transaction commit. it has to in order of 1,2,3,4,5 then 6

once we post the message , downstream application will be accessing the same tables which we are inserting on this transaction explained above.

can anyone guide me on this ?? how the commit of the transaction works ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

0

The commit order is just as you expect it to be, but keep in mind a couple of things:
1. As I understand, you migth have only one transaction going. This transaction will start on the message receive, and the other operations will add onto this single transaccion (this is the default behaviour in many transactional APIs).
Meaning you have ONLY one transaction and thus ONLY ONE global commit (it will actually be 2 commits, one to Database system, and one to queue system).
This also means that any failure resulting in rollback will affect both database and queue systems (the message will go back to queue or retry queue if configured).

To give you a proper answer I would need to know how do you want it to work.

  • If it is like this: "Even when the last step fails, the message is considered succesful and the database changes should be commited" For this you might need to envelop those steps in a separate transaction (You can check the spring documentation for Transactional annotation Spring Transactional
  • If it is something different I would need to know more details.
Jhilton
  • 420
  • 3
  • 7