Java 使用 TransactionManager 实现两阶段提交
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11237137/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java Implemeting Two Phase Commit with TransactionManager
提问by aumanets
I need to implement Two phase commit protocol using TransactionManager and ResourceManager. I've been googling this for hours and can't find anything useful. I know how protocol works, but I don't know where to begin this implementation. Could anyone point me in right direction?
我需要使用 TransactionManager 和 ResourceManager 实现两阶段提交协议。我已经用谷歌搜索了几个小时,找不到任何有用的东西。我知道协议是如何工作的,但我不知道从哪里开始这个实现。有人能指出我正确的方向吗?
采纳答案by tjg184
I would start by looking at what Spring has to offer with transaction management. They have great support for switching out transaction managers. You did not specify how you're running your application (i.e. what app server), but each app server has an implementation of a JTA transaction manager. Spring offers pluggable transaction manager implementations for several app servers . For example, they have one for IBM WebSphere (org.springframework.transaction.jta.WebSphereUowTransactionManager). This will allow your application to switch the transaction managers much easier.
我将首先看看 Spring 为事务管理提供了什么。他们非常支持更换事务管理器。您没有指定如何运行您的应用程序(即什么应用程序服务器),但每个应用程序服务器都有一个 JTA 事务管理器的实现。Spring 为多个应用服务器提供了可插入的事务管理器实现。例如,他们有一个用于 IBM WebSphere (org.springframework.transaction.jta.WebSphereUowTransactionManager)。这将使您的应用程序更容易切换事务管理器。
Below is a Spring reference. Note, 2 phase commit stuff is often found in relation to global transaction management (versus local transaction management).
下面是一个 Spring 参考。请注意,2 阶段提交内容通常与全局事务管理(相对于本地事务管理)有关。
http://static.springsource.org/spring/docs/3.0.x/reference/transaction.html
http://static.springsource.org/spring/docs/3.0.x/reference/transaction.html
Provide your app server and you might get some better answers, too.
提供您的应用服务器,您也可能会得到一些更好的答案。
回答by jediz
Have a look at Atomikos implementation. http://www.atomikos.com/Documentation/TwoPhaseCommitWithTomcatSpringJMSAndJDBC
看看 Atomikos 的实现。 http://www.atomikos.com/Documentation/TwoPhaseCommitWithTomcatSpringJMSAndJDBC