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?
2 Answers
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.
Below is a Spring reference. Note, 2 phase commit stuff is often found in relation to global transaction management (versus local transaction management).
http://static.springsource.org/spring/docs/3.0.x/reference/transaction.html
Provide your app server and you might get some better answers, too.
Have a look at Atomikos implementation. http://www.atomikos.com/Documentation/TwoPhaseCommitWithTomcatSpringJMSAndJDBC