1 / 19

EJB Transactions

EJB Transactions. Distributed Transactions. EJB allows application developers to write applications that atomically update data in multiple databases may be distributed across multiple sites sites may use EJB Servers from different vendors

tommya
Download Presentation

EJB Transactions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EJB Transactions

  2. Distributed Transactions • EJB allows application developers to write applications that atomically update data in multiple databases • may be distributed across multiple sites • sites may use EJB Servers from different vendors • The enterprise Bean Provider and the client application programmer are not exposed to the complexity of distributed transactions.

  3. ACID Properties • Atomicity. In a transaction involving two or more discrete pieces of information, either all of the pieces are committed or none are. • Consistency. A transaction either creates a new and valid state of data, or, if any failure occurs, returns all data to its state before the transaction was started. • Isolation. A transaction in process and not yet committed must remain isolated from any other transaction. • Durability. Committed data is saved by the system such that, even in the event of a failure and system restart, the data is available in its correct state.

  4. Programmatic vs. Declarative Transaction Demarcation • Bean-managed transaction demarcation • enterprise bean code demarcates transactions using javax.transaction.UserTransaction • accesses between UserTransaction.begin and UserTransaction.commit calls are part of a transaction • Container-managed transaction demarcation • container demarcates transactions per instructions provided by the Application Assembler in the deployment descriptor

  5. Container-Managed Transaction Demarcation • NotSupported - container invokes enterprise Bean method with an unspecified transaction context • Required - container invokes enterprise Bean method with a valid transaction context • Supports • If the client calls with a transaction context, same as Required • If the client calls without a transaction context, same as NotSupported

  6. Container-Managed Transaction Demarcation - 2 • RequiresNew - container invokes enterprise Bean method with a new transaction context • Mandatory - container invokes enterprise Bean method with the client’s transaction context • Never - container invokes an enterprise Bean method without a transaction context • client is required to call without a transaction context

  7. Isolation Levels • Describes the degree to which access to a resource manager by a transaction is isolated from other concurrently executing transactions • Part of the EJB 1.0 specification -- has been eliminated in EJB 1.1! • API for managing an isolation level is resource-manager specific • bean provider may specify the same or different isolation levels for each resource manager

  8. Updates to Multiple Databases Client Server X Y DB A DB C DB B • Multiple databases • Single transaction

  9. Updates to Multiple Databases in Same Transaction EJB Server EJB Server client Y X DB B DB A

  10. EJB Server client DB X begin commit TP Y EJB Server Updates to Multiples Databases on Multiple Servers

  11. Two-Phase Commit (2PC) • JDBC 1.2 does not support XA two phase commit • impossible for an EJB server using JDBC 1.2 to directly support for distributed transactions • Distributed transactions requires the existence of database drivers that support XA 2PC • in most cases, developers are relying on the vendor to provide database drivers

  12. Relationship to JTA and JTS • Java Transaction API (JTA) • Java Transaction Service (JTS)

  13. Java Transaction API (JTA)

  14. Java Transaction API (JTA) • JTA specifies the interfaces between a transaction manager and the other parties involved in a distributed transaction processing system • application programs • resource managers • application server

  15. Java Transaction Service (JTS) • Java binding of the CORBA Object Transaction Service (OTS) 1.1 specification • Provides transaction interoperability using the standard IIOP protocol for transaction propagation between servers • Intended for vendors who implement transaction processing infrastructure for enterprise middleware • may be used by an EJB Server vendor as the underlying transaction manager

  16. EJB Relationship to JTA and JTS • Does not require the EJB Container to support the JTS interfaces • Requires that the EJB Container support the javax.transaction.UserTransaction • interface defined in JTA • Does not require support for • JTA resource manager (XAResource) • application server interfaces

  17. Summary • Transaction-based systems can be implemented simply using EJB • Transactions are not simple -- transaction behavior is affected by choice of • session bean or entity bean • statefull or stateless session bean • bean-managed vs. container-managed transaction demarcation • transaction attributes • lots more stuff!

  18. References • [ 1 ] Java Transaction API (JTA). http://java.sun.com/products/jta. • [ 2 ] Java Transaction Service (JTS). http://java.sun.com/products/jts. • [ 3 ] OMG Object Transaction Service. http://www.omg.org/corba/sectrans.htm#trans.

  19. For More Information... • Telephone 412 / 268-5800 • Fax 412 / 268-5758 • Email rcs@sei.cmu.edu • World Wide Web http://www.sei.cmu.edu • U.S. mail Customer Relations Software Engineering Institute Carnegie Mellon Pittsburgh, PA 15213-3890

More Related