Spring Integration and Transaction with JMS and DB

半城伤御伤魂 提交于 2019-12-08 02:48:02

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/18184035/spring-integration-and-transaction-with-jms-and-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!