关于JTA事务
事务管理器与数据库连接的关系
特别是JTA事务与数据库Connection之间的关系。
java事务分为JDBC事务即驱动自带的事务管理器和JTA事务,JTA事务常见的实现有JBoss的事务管理器和JOTM实现,前者常与Jboss数据源结合使用(包括JBoss实现的数据库连接池),后者与xapool(支持分布式事务)配合使用。
当出现高并发事务,同一事务内操作,前面插入的数据后面查询不出来,原因很可能是一个事务内的连接被切换了,出现这种问题的原因是事务内的连接没进行管理。目前spring已经提供比较好的管理实现,可以参考使用。
经验证JOTM与XAPool结合并不稳定,存在较多不确定性稳定。
Open source JTA implementations
There exist a number of active (as of September 2010) open source JTA implementations.
JBossTS
JBossTS, formerly known as Arjuna Transaction Service, comes with a very robust implementation, which supports both the JTA and JTS APIs. JBossTS comes with a recovery service, which could be run as a separate process from your application processes. JBossTS is the default transaction manager for JBoss AS. It does not support out-of-the box integration with the Spring framework, but it is easy to integrate.
Atomikos TransactionsEssentials
Atomikos TransactionsEssentials's documentation and literature on the internet show that it is a production quality implementation, which also supports recovery and some exotic features beyond the JTA API. Atomikos provides out-of-the-box Spring integration along with some nice examples. It also provides support for pooled connections for both database and JMS resources.
Bitronix JTA
Bitronix claims to support transaction recovery as well as or even better than some of the commercial products. Bitronix also provides connection pooling and session pooling out of the box.