2
votes

I am using spring integration to send information to other systems via JMS. Currently in the system we have the following steps:

  1. update a status in the oracle database to say "Approved"
  2. send a JMS message off to external system.
  3. commit

a. So what if sending of JMS at (2) fails? How can we know and roll back DB? b. What if commit at (3) fails? How do we roll back?

Code or sample config example would be helpful.

Thanks GM

2

2 Answers

3
votes

You may as well use Spring Data's ChainedTransactionManager for Best Effort 1PC. This is as safe as XA, but you will have to deal with duplicate messages at the reciever side, which you would have to anyway, if not both systems use XA consistently. This blog post describes how to decouple both incoming and outgoing transaction handling using best effort 1PC.

3
votes

You can use Spring Transaction Synchronization (supported by Spring Integration) to synchronize the two transactions; this provides Best Effort 1PC as discussed in Dr. Dave Syer's Javaworld Article. If you need absolute guarantee, you may need to use XA.