Transactions
JCA specifies several levels of transaction support for resource adapters. The kind of
transactions that your resource adapter supports is specified in its ra.xml
file.
There are essentially three options: none (for example, with the CICS EPI connector), local
transactions (for example, with a CICS ECI connector), and global transactions (for example,
with an IMS connector). The following example configures the global option:
<connector>
<resourceadapter>
<!-- <transaction-support>NoTransaction</transaction-support> -->
<!-- <transaction-support>LocalTransaction</transaction-support> -->
<transaction-support>XATransaction</transaction-support>
<resourceadapter>
<connector>
For global transactions, you can use Spring’s generic transaction infrastructure to
demarcate transactions, with JtaTransactionManager
as the backend (delegating to the Java
EE server’s distributed transaction coordinator underneath).
For local transactions on a single CCI ConnectionFactory
, Spring provides a specific
transaction-management strategy for CCI, analogous to the DataSourceTransactionManager
for JDBC. The CCI API defines a local transaction object and corresponding local
transaction demarcation methods. Spring’s CciLocalTransactionManager
executes such
local CCI transactions in a fashion that is fully compliant with Spring’s generic
PlatformTransactionManager
abstraction. The following example configures a CciLocalTransactionManager
:
<jee:jndi-lookup id="eciConnectionFactory" jndi-name="eis/cicseci"/>
<bean id="eciTransactionManager"
class="org.springframework.jca.cci.connection.CciLocalTransactionManager">
<property name="connectionFactory" ref="eciConnectionFactory"/>
</bean>
You can use both transaction strategies with any of Spring’s transaction demarcation
facilities, be it declarative or programmatic. This is a consequence of Spring’s generic
PlatformTransactionManager
abstraction, which decouples transaction demarcation from
the actual execution strategy. You can switch between JtaTransactionManager
and
CciLocalTransactionManager
as needed, keeping your transaction demarcation as-is.
For more information on Spring’s transaction facilities, see Transaction Management.