开发者

JMS/MDB rollback

开发者 https://www.devze.com 2023-04-04 15:20 出处:网络
We have a app开发者_如何学运维lication, which reads of JMS and does some database transactions, all as part of one XA transaction..

We have a app开发者_如何学运维lication, which reads of JMS and does some database transactions, all as part of one XA transaction.. If we find the message has some problems, we want to rollback the database, but we don’t want the rollback off JMS to have us read the message again(we don't want the MDB to trigger the entire process one more if rollback was previously initiated).


To be sure I understand you correctly: you have a transactional message-driven bean that performs some actions on database. You still want the MDB to be a part of XA transaction, but you don't want the database actions to influence the state of the transaction in which the MDB takes part in.

That being said, there are two solutions:

  1. If the MDB runs within a container-managed transaction, wrap all the database actions into an EJB with @REQUIRES_NEW annotation — unless they're already all run in such transactional context.

  2. If your MDB is bean-managed, the message delivery is NOT a part of transaction, so it will not be redelivered, no matter what — section 5.4.12 of EJB Core Contracts and Requirements:

    When a message-driven bean using bean-managed transaction demarcation uses the javax.transaction. UserTransaction interface to demarcate transactions, the message receipt that causes the bean to be invoked is not part of the transaction.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号