background image

Transaction Timeouts

<< JDBC or JTA transactions | Updating Multiple Databases >>
<< JDBC or JTA transactions | Updating Multiple Databases >>

Transaction Timeouts

Methods Not Allowed in Bean-Managed Transactions
Do not invoke the getRollbackOnly and setRollbackOnly methods of the EJBContext
interface in bean-managed transactions. These methods should be used only in
container-managed transactions. For bean-managed transactions, invoke the getStatus and
rollback
methods of the UserTransaction interface.
Transaction Timeouts
For container-managed transactions, you can use the Admin Console to configure the
transaction timeout interval. See
"Starting the Admin Console" on page 69
.
1. In the Admin Console, expand the Configuration node and select Transaction Service.
2. On the Transaction Service page, set the value of the Transaction Timeout field to the value
of your choice (for example, 5).
With this setting, if the transaction has not completed within 5 seconds, the EJB container
rolls it back.
The default value is 0, meaning that the transaction will not time out.
3. Click Save.
For enterprise beans with bean-managed JTA transactions, you invoke the
setTransactionTimeout
method of the UserTransaction interface.
Updating Multiple Databases
The Java EE transaction manager controls all enterprise bean transactions except for
bean-managed JDBC transactions. The Java EE transaction manager allows an enterprise bean
to update multiple databases within a transaction. The figures that follow show two scenarios
for updating multiple databases in a single transaction.
In
Figure 33­2
, the client invokes a business method in Bean-A. The business method begins a
transaction, updates Database X, updates Database Y, and invokes a business method in
Bean-B
. The second business method updates Database Z and returns control to the business
method in Bean-A, which commits the transaction. All three database updates occur in the same
transaction.
Updating Multiple Databases
Chapter 33 · Transactions
1005