Sometimes the order of commits is important. This mostly happens if you have the following use case:
- A receives a message, and uses XA JMS drivers to do so (starting a new transaction with participant no. 1)
- A writes stuff to db (participant no. 2)
- A sends a JMS message to B, and uses XA JMS drivers to do so (re-using participant no. 1)
- A commits the XA transaction
Now participant no. 1 will be committed before participant no. 2, which means that there’s a race condition between when process B consumes the message and when the database transaction has completed.
Use separate jms connection factories for receive/send: this will give 3 participants, and a commit order (for the participants in the XA transaction) as: (1)jms-receive (2) db (3) jms-send.