Java Reference
In-Depth Information
DB2
Application
Oracle
Legacy
CICS
Application
Message
Queue
Figure 7.2
Example of global transaction scope
7.4.1
Using active or passive transactions
i BATIS can participate in a global transaction in one of two ways: actively or pas-
sively. When configured to actively participate, i BATIS will look for the global
transaction context and attempt to manage it appropriately. This means that i BA-
TIS can check the state of an existing transaction or start one if necessary. It will
also be able to set the state to “rollback-only” in the event of an error, which will
notify other participating resources that the transaction should not be committed.
When configured to passively participate in a global transaction, i BATIS will
simply ignore all instructions to start, commit, and end transactions. It will throw
exceptions in the case of an error, which i BATIS assumes will cause the transaction
to be rolled back.
Deciding which to use is sometimes a matter of just trying it. Different applica-
tion servers and different architectures will work better one way or the other. The
good thing is, it's very easy to switch back and forth. Listing 7.4 shows the configu-
ration for both active participation and passive participation.
Listing 7.4
Global transaction manager configuration options
<transactionManager type="JTA">
<property name="UserTransaction"
value="java:/ctx/con/someUserTransaction"/>
<dataSource type="JNDI">
<property name="DataSource"
value="java:comp/env/jdbc/someDataSource"/>
</dataSource>
</transactionManager>
Active participation
<transactionManager type="EXTERNAL">
<dataSource type="JNDI">
Passive participation
 
Search WWH ::




Custom Search