eWebProgrammer
Distributednetworks GofPatterns
prev prev prev next
Course navigation
Lesson 1
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.
Managed transactions
You will be introduced to the three different ways a transaction can be managed. They are:
  1. Client-managed transactions--the client begins and commits the transaction
  2. Bean-managed transactions--the bean starts and controls the transaction
  3. Container-managed transactions-the EJB knows nothing about the transaction that the container is managing for it
Session synchronization
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.
Exceptions
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.
Course navigation