C++ 中的 XA 分布式事务
有没有好的C++框架来实现XA分布式事务?
我所说的“好”一词是指可用、简单(并不意味着“容易”)、结构良好。
由于学习原因,目前我正在按照 X/Open XA 规范进行个人实现。
先感谢您。
Is there a good C++ framework to implement XA distributed transactions?
With the term "good" I mean usable, simple (doesn't imply "easy"), well-structured.
Due to study reasons, at the moment I'm proceeding with a personal implementation, following X/Open XA specification.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道有任何成熟程度的开源或免费交易监视器,尽管 此链接< /a> 确实有一些扇出。 现有的商业产品是BEA的Tuxedo, Tibco 的企业消息服务(实际上是一个事务性消息队列管理器(如 IBM 的 MQ)和 Transarc 的 Encina(现归 IBM 所有)。 这些系统都非常昂贵。
如果您想自己制作(并通过填补开源软件领域的空白顺便为自己赢得一点名气),请获取 格雷和路透社。
这是关于事务处理系统架构的权威著作,由该领域的两位最重要的专家撰写。
有趣的是,他们声称可以用大约 10,000 行 C 语言实现一个工作的 TP 监视器。这实际上听起来很合理,因为它所做的并不是那么复杂。 有时我也想尝试一下。
本质上,您需要创建一个作为守护进程运行的分布式事务协调器。 您将需要让资源管理器协议从中运行,因此将此作为原型开始可能是一个好的开始。 如果您可以让它独立回滚或提交事务,您就拥有了 TM-RM 接口的基础。
规范中定义的 XA API 是控制事务管理器的 API。 严格来说,您不需要创建一个 3 层架构来使用这种分布式事务,但如果没有 TP 监视器,它们或多或少是毫无意义的。 如何从前端到中间层进行通信可以留给读者作为练习。 您可能最好使用现有的 ORB,其中有几个很好的开源实现可用。
根据您是否想要使 DTC 和应用程序服务器分离进程(这可能是为了稳定性所需要的,但并非绝对必要),您也可以使用 ACE 作为 DTC 服务器的基础。
如果您想制作高性能的中间层服务器,请查看 Douglas Schmidt 的 ACE框架。 它附带了一个名为 TAO 的 ORB,并且足够灵活,允许您或多或少地使用您喜欢的任何线程模型。 使用它是学习它和编写自己的代码以及调试所有同步和并发问题之间的权衡。
I am not aware of an open-source or free transaction monitor that has any degree of maturity, although This link does have some fan-out. The incumbent commercial ones are BEA's Tuxedo, Tibco's Enterprise Message Service (really a transactional message queue manager like IBM's MQ) and Transarc's Encina (now owned by IBM). These systems are all very expensive.
If you want to make your own (and incidentally make a bit of a name for yourself by filling a void in the open-source software space) get a copy of Grey and Reuter.
This is the definitive work on transaction processing systems architecture, written by two of the foremost experts in the field.
Interestingly, they claim that one can implement a working TP monitor in around 10,000 lines of C. This actually sounds quite reasonable, as what it does is not all that complex. On occasion I have been tempted to try.
Essentially you need to make a distributed transaction coordinator that runs as a daemon process. You will need to get the resource manager protocol working from it, so starting with this as a prototype is probably a good start. If you can get it to independently roll back or commit a transaction you have the basis of the TM-RM interface.
The XA API as defined in the spec is the API to control the transaction manager. Strictly speaking, you don't need to make a 3-tier architecture to use distributed transactions of this sort, but they are more or less pointless without a TP monitor. How you communicate from the front-end to the middle-tier can be left as an exercise for the reader. You are probably best off using an existing ORB, of which there are several good open-source implementations available.
Depending on whether you want to make the DTC and the app server separate processes (which is possibly desirable for stability but not strictly necessary) you could also use ACE as a basis for the DTC server.
If you want to make a high-performance middle-tier server, check out Douglas Schmidt's ACE framework. This comes with an ORB called TAO, and is flexible enough to allow you to use more or less any threading model that takes your fancy. Using this is a trade-off between learning it and the effort of writing your own and debugging all the synchronisation and concurrancy issues.
也许对于您的任务来说已经很晚了,但它对其他用户可能很有用: LIXA 不是 "框架”,但它提供了 TX 事务划分规范的实现并支持大多数 XA 功能。
TX 规范适用于 C 和 COBOL 语言,但将 C 版本集成到 C++ 项目中应该毫不费力。
Maybe quite late for your task, but it can be useful for other users: LIXA is not a "framework", but it provides an implementation for the TX Transaction Demarcation specification and supports most of the XA features.
The TX specification is for C and COBOL languages, but the integration of the C version inside a C++ project should be effortless.
其他选项是开源 Enduro/X 分布式事务处理框架,它允许编写简单的 C/C++可以与资源管理器(例如数据库)一起操作的服务,并且能够提交或中止由在使用不同资源/数据库的相同/不同物理服务器上的多个不同可执行文件完成的工作。
内部使用 XA 2PC。
Other option is open source Enduro/X distributed transaction processing framework which allows to write simple C/C++ services which may operate with resource managers (e.g. databases) and gives capability to commit or abort works done by several different executables on same/different physical servers worked with different resources/databases.
Internally XA 2PC is used there.