380 likes | 1.2k Views
Java Transaction API. Prepared by Mehmet Küçüksayan Mustafa Ecmel Özdemir. Outline. Transaction Java Transaction Java API Java Transaction API Transaction and Resource Managers JTA vs JDBC JTA vs EJB Extensions to JTA Advantages and Disadvantages of JTA. Transaction.
E N D
Java Transaction API Prepared by Mehmet Küçüksayan Mustafa Ecmel Özdemir
Outline • Transaction • Java Transaction • Java API • Java Transaction API • Transaction and Resource Managers • JTA vs JDBC • JTA vs EJB • Extensions to JTA • Advantages and Disadvantages of JTA
Transaction • is a complete unit of work that completes succesfully or results with unaltered state. • has two types; • Local transactions • Distributed transactions
Java Transaction • Java Transaction Service(JTS) - specifies the implementation of a Java transaction manager. • Java Transaction API(JTA) - calls the lower-level JTS methods.
Java API • consists of • Java classes • Packages • Interfaces • Each version of Java has its own API
Java Transaction API • high level, implementation independent, protocol independent API. • offered by J2EE technology. • provides reliable environment for the J2EE container.
Java Transaction API • enables applications to perform distributed transactions. • specifies standard Java interfaces between a transaction manager and other components involved in a distributed transaction system. • transaction manager, application, application server, and resource manager take roles in.
Transaction and Resource Managers • Transaction manager decides whether to commit or rollback at the end of the transactionin a distributed system and coordinates various resource managers. • Resource manager is responsible from the controlling of accessing the common resources in the distributed system.
Transaction Environment Schema Interfaces: • 1. UserTransaction • 2. Transaction Manager • 3. XA Resource
JTA vs JDBC • JDBC driver has to support both normal JDBC interactions and XAResource part of JTA. • XA protocol enables resource manager to take place in the transaction. • JDBC is responsible for "translating" between resource manager and transaction manager.
JTA vs JDBC • Applicationserver, JDBC driver and transaction manager care about the distributed transactionmanagement. • Application developer should not enter the scope of the transaction.
JTA vs EJB • EJB container is responsible for transaction processing. • A stateless session bean can obtain a UserTransaction object via the EJBContext using the getUserTransaction() method. • Session bean usage could be bundled together with a JTA UserTransaction object where each session bean is deployed on a different EJB server.
Extensions to JTA Extensions to the JTA can be provided. For example; • Clients can suspend and resume the transaction • Users can get and set transaction properties. • Users can obtain the current transaction manager.
Advantages vs Disadvantages + provides modularity. + guaranteesACID properties. + application developer does not need to care about the transaction management - does not support nested transactions.