处理不同 EAR 上的交易

发布于 2024-08-14 11:34:44 字数 306 浏览 12 评论 0原文

据我们所知,处理多个 EAR 和同一事务的最佳实践是什么,我们需要应用 XA 概念才能使事务正常工作。但显然在我们一直致力于的当前项目中,这对于创建和更新来说并不是严格必要的;但是,如果我们尝试从实体中检索任何集合,我们会收到一条错误,指出该交易不是活动交易或已关闭,但如果我们更新 Ear A 中的实体 A 并更新 Ear B 中的实体 B,则当实体 A 正常工作时,它可以正常工作。实体 B 有不同的数据源,此时我们对此感到非常困惑,因为我们还没有配置任何 xa 数据源。处理这个问题的最佳方法是什么?事务由 bean 处理,而不是由容器处理,并且 EAR A 和 EAR B 之间的数据源不同

what is the best practice to handle multiple EARs and the same transaction, as far as we know we need to apply XA concepts in order transaction works correctly. but apparently in currents project that we've been working on, this is not strictly necessary for creates and updates; however if we try to retrieve any collection from an entity we get an error that say there its not an active transaction or it was closed, but if we update Entity A in Ear A and update Entity B in Ear B it works perfectly when Entity A and Entity B has different datasources, at this point we are so confused about that, because we haven't configure any xa datasource yet. how is the best approach to work with this. transaction are handles by beans and not by the container and datasource are different between EAR A and EAR B

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅的被狗咬 2024-08-21 11:34:44

当您想要在单个事务中使用多个资源(数据库、JMS 资源、JCA 连接器)时,您需要 XA 事务(也称为“全局事务”)。XA 事务涉及 JTA 事务管理器,用于通过有关 XA 的更多详细信息,请参阅此精彩的两阶段提交 (2PC) 协议 XA 公开

(...)如果我们更新 Ear A 中的实体 A 并更新 Ear B 中的实体 B,当实体 A 和实体 B 具有不同的数据源时,它可以完美地工作

您如何执行该更新(我的意思是,从哪里)? “它有效”到底是什么意思?您确定在出现问题时回滚这两个更新吗?如果不使用全局事务,我会感到惊讶。你能澄清一下吗?

When you want to work with multiple resources (databases, JMS resources, JCA connectors) in a single transaction, you need an XA transaction (also know as a "global transaction). An XA transaction involves a JTA transaction manager for the coordination through the two-phase commit (2PC) protocol. For more details on XA, see this wonderfull XA Exposed post from Mike Spille.

(...) if we update Entity A in Ear A and update Entity B in Ear B it works perfectly when Entity A and Entity B has different datasources

How do you perform that update (I mean, from where)? What do you mean exactly by "it works"? Are you sure both updates are rollbacked in case of problem? Without using a global transaction, I'd be surprised if they are. Can you clarify this a bit?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文