EJBs and Distributed Transactions
This lesson introduces you to distributed transactions.
In the first course in this series you programmed session beans. However, the course ignored transactions.
In most industrial-strength applications based on EJBs, transactions are used to ensure data integrity.
It is important that you understand how they work within the EJB architecture and that you know how to write beans that use them.
JTS and JTA
You will be introduced to the two Java packages, Java Transaction Services (JTS) and the Java Transaction API (JTA).
JTS is the underlying architecture that supports distributed transactions and JTA is the programmers' API used to access the services.
You will be introduced to the three different ways a transaction can be managed. They are:
- Client-managed transactions--the client begins and commits the transaction
Bean-managed transactions--the bean starts and controls the transaction
Container-managed transactions-the EJB knows nothing about the transaction that
the container is managing for it
Session beans can be involved in transactions.
If they are container-managed, the session bean may still have a need to know or affect the outcome of a transaction.
The SessionSynchronization object allows that session bean access to the transaction.
The final part of this module covers the exceptions that may be thrown by, and caught from, the transaction service.
Managing transactions can be difficult. This information will make it easy for you to write programs that work correctly, no matter what happens to your transaction.