什么是“正确的”?使用 Spring 从一个 EAR 文件到另一个 EAR 文件调用事务安全的方法?

发布于 2024-10-07 09:01:11 字数 153 浏览 0 评论 0原文

我有两个 Spring 应用程序 A 和 B,每个应用程序都位于一个单独的 EAR 文件中。现在我想从 A 呼叫到 B,反之亦然,甚至可能是 A -> 。 B->一个或更多。

调用必须交易安全

推荐的方法是什么?

I have two spring applications A and B, each within an individual EAR file. Now I want to call from A to B and vice versa, maybe even A -> B -> A or more.

The calls have to be transactionally safe.

What is the recommended approach?

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

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

发布评论

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

评论(2

半边脸i 2024-10-14 09:01:11

确保安全的唯一方法是使用由容器管理的 JTA 事务。 Spring 通过其 JtaTransactionManager 支持这些,因此您可以像 Spring 中的任何其他事务一样编写事务逻辑。所有数据源必须由容器管理,而不是由应用程序管理。

The only way to keep this safe is to use JTA transactions, managed by the container. Spring supports these via its JtaTransactionManager, so you can write your transactional logic the same as any other transactions in Spring. All data sources must be managed by the container, not by the applications.

沫雨熙 2024-10-14 09:01:11

进行同步事务(通过两次提交)从一个 EAR 到另一个 EAR 的调用的唯一方法是使用远程 EJB :(

如果在您的情况下可能的话,我宁愿使用 JMS 进行异步调用,发送该消息将与您的事务结合在一起,但接收方将无法回滚您的事务,因为远程 EJB 调用可以回滚您的事务。

The only way to make a synchronous transactional -- with two face commit -- call from one EAR to another is to use remote EJBs :(

If it is possible in your case I would rather go for an asynchronous call using JMS, the sending of the message will be coupled with your transaction but the receiver won't be able to rollback your transaction as it would be possible with a remote EJB call.

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