Transactions
A Java program typically will use the JDBC API to access the underlying database in some transactional context. Transactions are used to ensure that multiple operations are executed as an atomic unit, and to maintain a consistent view of data during concurrent access. All JDBC-compliant products are required to offer support for local transactions, including features such as auto-commit, transaction isolation levels, and savepoints (if the product is JDBC 3.0-compliant). Some J2EE services, such as entity beans and transactional JMS message delivery, require distributed transactions that span multiple connections and/or resources.
The Java Transaction API (JTA) provides high-level client access to distributed transactions. This framework defines a transaction manager that controls transaction boundaries and upholds the two-phase commit (2PC) semantics across multiple resource managers. WebLogic Server acts as the Transaction Processing (TP) monitor, providing the runtime support for managing the boundaries of your transactions. It protects the integrity of your transactions and ensures that all resources participating in a transaction are updated correctly, even after a system failure.
This chapter focuses on WebLogic's support for transactions. We look at distributed transactions, transaction attributes, and the role of the 2PC protocol. We examine how the EJB container manages EJBs when they are involved in distributed transactions, and how EJBs can create their own transaction boundaries. We also look at WebLogic's transaction service, its features, and how you can use the JTA interface to initiate your own transactions. In addition, we look at how to configure JTA transactions and monitor them through WebLogic's transaction logs. Finally, we explore how WebLogic allows you to recover failed transactions after a server crash, and offload the transaction recovery onto a backup server, if needed.