C++ 之间 Oracle 事务的传播 和爪哇

发布于 2024-07-05 14:35:43 字数 527 浏览 5 评论 0原文

我们有一个现有的 C++ 应用程序,我们将逐步将其替换为新的基于 Java 的系统。 在我们用 Java 完全重新实现所有内容之前,我们期望 C++ 和 Java 必须相互通信(RMI、SOAP、消息传递等 - 我们尚未决定)。

现在我的经理认为我们需要 Java 和 C++ 端参与同一个 Oracle DB 事务。 这与单个进程协调 2 个事务资源(例如数据库和消息队列)的常见分布式事务问题相关,但又不同。

我认为从性能和稳定性的角度来看,跨进程传播事务是一个糟糕的主意,但我仍然会被要求提供解决方案。

我熟悉 XA 事务,并且已经使用 JBoss 事务管理器完成了一些工作,但是我的谷歌搜索没有发现任何关于在两个进程之间传播 XA 事务的好信息。

我们在 Java 端使用 Spring,他们的文档明确指出他们不提供事务传播的任何帮助。

我们不打算使用传统的 Java EE 服务器(例如:IBM Websphere),它可能支持传播(但我找不到任何明确的文档)。

非常感谢任何有关解决方案的帮助或指示。

We have an existing C++ application that we are going to gradually replace with a new Java-based system. Until we have completely reimplemented everything in Java we expect the C++ and Java to have to communicate with each other (RMI, SOAP, messaging, etc - we haven't decided).

Now my manager thinks we'll need the Java and C++ sides to participate in the same Oracle DB transaction. This is related to, but different from the usual distrbuted transaction problem of having a single process co-ordinate 2 transactional resources, such as a DB and a message queue.

I think propagating a transaction across processes is a terrible idea from a performance and stability point-of-view, but I am still going to be asked for a solution.

I am familiar with XA transactions and I've done some work with the JBoss Transaction Manager, but my googling hasn't turned up anything good on propagating an XA transaction between 2 processes.

We are using Spring on the Java side and their documentation explicitly states they do not provide any help with transaction propagation.

We are not planning on using a traditional Java EE server (for example: IBM Websphere), which may have support for propagation (not that I can find any definitive documentation).

Any help or pointers on solutions is greatly appreciated.

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

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

发布评论

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

评论(3

要走就滚别墨迹 2024-07-12 14:35:43

Laurent Schneider 的博客上有一个在 Oracle 中使用 DBMS_XA 包的示例允许多个会话在同一事务中工作。 因此,可以让 Java 和 C++ 会话参与同一事务,而不需要任何额外的协调器。

或者,您可以考虑使用工作区管理器。 最初设计的目的是支持极其长时间运行的事务(即为拟议的开发操作大量空间数据)。 本质上,您可以创建一个工作区,在您的情况下,它大致相当于一个命名事务。 Java 和 C++ 代码都可以进入该工作区(从单独的会话),并且都可以在该工作区中操作和提交数据。 当事务完成后,您可以将工作区合并到 LIVE 工作区,这相当于在正常事务中进行提交。

另一方面,我强烈同意您的初步评估,即从性能、稳定性、简单性和维护的角度来看,协调进程之间的事务很可能是一个坏主意。 另一方面,这很可能是一个合法的业务需求,具体取决于 C++ 代码将如何退役(即是否可以以事务可以完全是 Java 或完全是 C++ 的方式替换代码)

There is an example on Laurent Schneider's blog of using the DBMS_XA package inside Oracle to permit multiple sessions to work in the same transaction. So it would be possible to have Java and C++ sessions participating in the same transaction without needing any sort of additional coordinator.

Alternately, you might consider using Workspace Manager. That was originally designed to support extremely long-running transactions (i.e. manipulating lots of spatial data for a proposed development). Essentially, you can create a workspace, which in your case would be roughly equivalent to a named transaction. Both the Java and C++ code could enter that workspace (from separate sessions) and both could manipulate and commit data in that workspace. When the transaction was complete, you could then merge the workspace to the LIVE workspace, which is equivalent to doing a commit in a normal transaction.

On the other hand, I would strongly agree with your initial assessment that coordinating transactions between processes is very likely to be a bad idea from a performance, stability, simplicity, and maintenance standpoint. On the other hand, it may well be a legitimate business requirement depending on how the C++ code is going to be retired (i.e. whether it is possible to replace code in such a way that transactions can be either exclusively Java or exclusively C++)

迷鸟归林 2024-07-12 14:35:43

我一直在使用 Hazlecast 消息传递和分布式内存锁来解决其中一些问题,但是使用这样的工具需要您在接触相同数据的部分重新设计软件。 C++ 客户端文档此处 Java 客户端此处

Oracle 还有一款名为 Oracle Coherence 的类似产品,可能会对您有所帮助,请参阅 锁定

此外,数据库还包含一个名为 Oracle Streams 高级队列< 的 MQ 系统/a> (事务性持久队列)在某些情况下可能会为您提供帮助。 Oracle AQ 与 Oracle 触发器集成良好。

此外,还有数据库更改通知可以帮助您更新缓存或通知进程更新,这可以与乐观离线锁定模式一起使用。

另请参阅软件事务内存

Apache Zookeeper 还可以帮助您处理分布式锁定

I have been using Hazlecast Messaging and Distributed memory locks to solve some of these concerns, however using such a tool would require that you redisign your software in those parts where you touch the same data. C++ client docs here Java client here

Oracle also has a similar product called Oracle Coherence that may help you, see locking in the dev guide.

Also the database contains a MQ system called Oracle Streams Advanced queueing ( transactional persistent queues) that might help you in some situations. Oracle AQ integrates well with Oracle triggers.

Additionally there is the Database Change Notification that may help you update caches or notify processes of updates, this can be used together with the Optimistic Offline Lock pattern.

See also Software transactional memory

Apache Zookeeper can also help you with distributed locking.

谷夏 2024-07-12 14:35:43

我相信 JBoss Transaction Manager 支持跨 Web 服务调用的 2pc tx 传播。 我想你可以用这种方式集成你的系统,但性能会很差。

I believe JBoss Transaction Manager supports 2pc tx propagation across web service calls. You could, I suppose integrate your systems that way, but the performance would stink.

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