j2ee‎ > ‎

Jave EE Transaction API(JTA1.1)

posted Jun 20, 2010, 7:25 PM by Kuwon Kang

4.2 Transaction Association and Connection Request Flow

This session provides a brief walkthrough of how an application server may handle a

connection request from the application. The figure that follows illustrates the usage of

JTA. The steps shown are for illustrative purposes, they are not prescriptive:

1. Assuming a client invokes an EJB bean with a TX_REQUIRED transaction

attribute and the client is not associated with a global transaction, the EJB

container starts a global transaction by invoking the

TransactionManager.begin method.

2. After the the transaction starts, the container invokes the bean method. As part

of the business logic, the bean requests for a connection-based resource using

the API provided by the resource adapter of interest.

3. The application server obtains a resource from the resource adapter via some

ResourceFactory.getTransactionalResource method.

4. The resource adapter creates the TransactionalResource object and the

associated XAResource and Connection objects.

5. The application server invokes the getXAResource method.

6. The application server enlists the resource to the transaction manager.

7. The transaction manager invokes XAResource.start to associate the current

transaction to the resource.

8. The application server invokes the getConnection method.

9. The application server returns the Connection object reference to the


10. The application performs one or more operations on the connection.

11. The application closes the connection.

12. The application server delist the resource when notified by the resource adapter

about the connection close.

13. The transaction manager invokes XAResource.end to disassociate the

transaction from the XAResource.

14. The application server asks the transaction manager to commit the transaction.

15. The transaction manager invokes XAResource.prepare to inform the resource

manager to prepare the transaction work for commit.

16. The transaction manager invokes XAResource.commit to commit the


This example illustrates the application server’s usage of the TransactionManager

and XAResource interfaces as part of the application connection request handling.