XA/JTA事务:在数据库更改可见之前,JMS消息已到达 [英] XA/JTA transaction: JMS message arrives before DB changes are visible

查看:148
本文介绍了XA/JTA事务:在数据库更改可见之前,JMS消息已到达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文是:

  • 生产者(JTA事务 PT )正在向JMS队列发送消息并进行数据库更新.
  • 消费者(JTA交易 CT )在相同的队列上进行侦听,并在收到消息时读取数据库;
  • 应用程序服务器-WebLogic,数据库-Oracle.
  • producer (JTA transaction PT) is both sending message to JMS queue and making DB update;
  • consumer (JTA transaction CT) listens on same queue and reads DB when message is received;
  • application server - WebLogic, DB - Oracle.

我观察到,如果已经收到相应的JMS消息( > PT 已提交?)

I've observed, that sometimes CT is not (yet?) able to see DB changes of PT, event if corresponding JMS message is already received (PT is committed?).

JTA似乎不能保证这种一致性(Jurgen Holler的演讲性能的交易选择" 中也证实了这一点).

It seems that JTA can't guarantee consistency of such kind (this was also confirmed in Jurgen Holler's presentation "Transaction Choices for Performance").

避免此类问题的最佳方法是什么(显而易见的除外-不使用JTA)?

What is the best way to avoid such problem (except obvious - not using JTA)?

谢谢.

推荐答案

因此,似乎没有简单,优雅且可靠的解决方案.在我们的案例中,决定依靠简单的重新交付机制(引发异常并在一定时间后让JMS消息重新交付).

So it seems there is no simple, elegant and fail-proof solution for that. In our case it was decided to rely on simple redelivery mechanism (throwing exception and letting JMS message to be redelivered after certain amount of time).

也考虑过:

  • 将DB数据源标记为,并期望最后一个资源提交优化(LRCO)起作用(因此部分控制XA事务中的提交顺序).由于对应用程序服务器(WL)内部的依赖性而被拒绝.

  • Marking DB datasource as and expecting Last Resource Commit Optimization (LRCO) to kick-in (thus partially controlling order of commits inside XA transaction). Rejected due to dependency to internals of application server (WL).

将DeliveryDelay设置为JMS消息,以便仅在一段时间(据说)数据库同步结束后才能使用它.由于缺乏保证而被拒绝,需要针对不同的环境进行微调.

Setting DeliveryDelay to JMS message, so it can be consumed only after some time, when (supposedly) DB sync is over. Rejected due to lack of guarantee and need to fine-tune it for different environments.

博客文章确实包含所有这些以及其他几个选项都涵盖了(但没有确定的选项).

Blog post mentioned in other answer indeed contains all these and several other options covered (but no definitive one).

这篇关于XA/JTA事务:在数据库更改可见之前,JMS消息已到达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆