Pax TransX aims at providing support for JTA/JTS transaction management in OSGi, along with resource pooling for JDBC and JMS.
This is the official source repository of the OPS4J Pax TransX project. Its licensed under the Apache Software License 2.0 by the OPS4J community.
You'll need a machine with Java 8 and Apache Maven 3 installed.
Checkout:
git clone git://github.com/ops4j/org.ops4j.pax.transx.git
Run Build:
mvn clean install
The latest release is 0.1.0 and can be found in Maven Central.
Pax-TransX provides features to easily integrate in Apache Karaf.
> repo-add mvn:org.ops4j.pax.transx/pax-transx-features/0.1.0/xml/features
> feature:install pax-transx-tm-narayana
The TransX Transaction Manager API aims to provide a common facade for transaction managers so that one can code against various transaction managers without caring about the specifics. In addition to the basic transaction management capabilities, the API provides a facade for:
The Transaction Manager is the main entry point of the API.
Transactional resources must be wrapped into ResourceFactories and registered in the Transaction Manager. This will trigger the recovery mechanism.
If a transactional resource does not support XA, the XAResource wrapping this resource should also implement [LastResource]. Transaction managers that support LRC will ensure that such resources are prepared last, ensuring some consistency even with no native XA support.
Pax TransX supports 3 different implementations based on the following transaction managers:
A JDBC DataSource with pooling and XA support can be created in the following way:
return ManagedDataSourceBuilder.builder()
.transactionManager(tm)
.name("h2invm")
.dataSource(xaDataSource)
.build();
A JMS ConnectionFactory with pooling an XA support can be created in the following way:
return ManagedConnectionFactoryBuilder.builder()
.transactionManager(tm)
.name("vmbroker")
.connectionFactory(new ActiveMQConnectionFactory(brokerUrl),
new ActiveMQXAConnectionFactory(brokerUrl))
.build();
Note that the wrapped ConnectionFactory will support JMS 2.0, only relying on JMS 1.1 for the underlying connection factories.