Java Transactions Service Presented by: Dina Sarhan Rana El Hattab.

Slides:



Advertisements
Similar presentations
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
Advertisements

21 Copyright © 2005, Oracle. All rights reserved. Oracle Application Server 10g Transaction Support.
COM vs. CORBA.
Distributed Transactions in Java EE Nikolai Tankov SAP Labs Bulgaria January 19th, 2008 Sofia, Bulgaria.
CORBA - Common Object Request Broker Architecture.
Transactions Celsina Bignoli Motivations Atomic operations –Group of operation that must all succeed or all fail Network or machine.
Approaches to EJB Replication. Overview J2EE architecture –EJB, components, services Replication –Clustering, container, application Conclusions –Advantages.
A brief look at CORBA. What is CORBA Common Object Request Broker Architecture developed by OMG Combine benefits of OO and distributed computing Distributed.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
Distributed Service Architectures Yitao Duan 03/19/2002.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
The Architecture of Transaction Processing Systems
July 23 th, 2005 Software Architecture in Practice RiSE’s Seminars Bass’s et al. Book :: Chapter 16 Fred Durão.
Version # Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department of Defense © 1999 by Carnegie.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
12-1 © Prentice Hall, 2004 Chapter 12: Design Elements Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey.
M.Sc. Course, Dept. of Informatics and Telecommunications, University of Athens S.Hadjiefthymiades “Web Application Servers” Basics on WAS WAS are necessary.
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Common Object Request Broker Architecture (CORBA) CS-328.
1 J2EE Components. 2 Application Servers relieve the programming burden for business distributed components. They provide support for system level services.
Enterprise Java Beans CS-422. Application Servers In the late 1980s and though the mid 1990s a number of corporations (Broadvision, Netscape…) marketed.
Enterprise Java Beans - (EJB)
© jGuru.com EJB Transactions. Transactions Simple Transaction –Transaction = more than one statement which must all succeed (or all fail) together.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
Enterprise Java Beans Part I Kyungmin Cho 2001/04/10.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
Enterprise JavaBeans. What is EJB? l An EJB is a specialized, non-visual JavaBean that runs on a server. l EJB technology supports application development.
Introduction to J2EE Architecture Portions by Kunal Mehta.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
Message-Driven Beans and EJB Security Lesson 4B / Slide 1 of 37 J2EE Server Components Objectives In this lesson, you will learn about: Identify features.
Java Transaction API Sean C. Sullivan
第十四章 J2EE 入门 Introduction What is J2EE ?
J2EE Structure & Definitions Catie Welsh CSE 432
Enterprise Java Beans Java for the Enterprise Server-based platform for Enterprise Applications Designed for “medium-to-large scale business, enterprise-wide.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
1 of of 25 3 of 25 ORBs (Object Request Broker) – A distributed software bus for communication among middleware services and applications – To.
J2EE Overview ver 1.0Page 1 © Wipro Technologies Talent Transformation J2EE Overview.
Transaction Services in Component Frameworks Bruce Kessler Comp250CBS March 2, 2004.
1 Java EE Programming Enterprise JavaBeans. 2 Topics J2EE Overview Enterprise JavaBeans Overview Enterprise Entity Beans Case Study How to build them.
1 Transactions Michael Brockway Sajjad Shami CG0165: Advanced Applications Development in Java Northumbria University School of Computing, Engineering.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Presented By:- Sudipta Dhara Roll Table of Content Table of Content 1.Introduction 2.How it evolved 3.Need of Middleware 4.Middleware Basic 5.Categories.
 Common Object Request Broker Architecture  An industry standard developed by OMG to help in distributed programming.
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
Copyright © 2002 ProsoftTraining. All rights reserved. Enterprise JavaBeans.
红杉树(中国)信息技术有限公司公司 地址:杭州市天目山路 176 号西湖数源软件园 11 号楼 3 层 电话: (86) Transaction & JAVA Fondy Wang 12/7/07.
©NIIT Introducing Enterprise JavaBeans (EJB) Lesson 1A / Slide 1 of 43J2EE Server Components Objectives In this lesson, you will learn about: The features.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
EJB Enterprise Java Beans JAVA Enterprise Edition
EJB. Introduction Enterprise Java Beans is a specification for creating server- side scalable, transactional, multi-user secure enterprise-level applications.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
JTA | Developer Conference JBoss Transactions Ivo Studenský JBoss QA Engineer, Jiří Pechanec JBoss QE Supervisor, Red Hat Sep 10th, 2009.
Prepared by Mehmet Küçüksayan Mustafa Ecmel Özdemir
Common Object Request Broker Architecture (CORBA)
CORBA Alegria Baquero.
Introduction to J2EE Architecture
Knowledge Byte In this section, you will learn about:
The OMG Approach (continued)
Inventory of Distributed Computing Concepts and Web services
CORBA Alegria Baquero.
Inventory of Distributed Computing Concepts
Component--based development
Component-based Applications
Enterprise Java Beans.
Knowledge Byte In this section, you will learn about:
Objectives In this lesson, you will learn about:
Copyright 1999 B.Ramamurthy
Presentation transcript:

Java Transactions Service Presented by: Dina Sarhan Rana El Hattab

The Java Transaction Service  The Java Transaction Service is a key element of the J2EE architecture. Together with the Java Transaction API, it enables us to build distributed applications that are robust to all sorts of system and network failures.  If you look at any source on J2EE, you'll find that only a small part of the material discusses the both Java Transaction Service (JTS) and the Java Transaction API (JTA). This does not undermine the importance of JTS as JTS gets less press than EJB technology because the services it provides to the application are largely transparent many developers are not even aware of where transactions begin and end in their application.

What is a Transaction?  What is an application's state?  A transaction can be defined as a related collection of operations on the application state.  In other words, a transaction is a unit of work done by multiple distributed components on shared data.  A transaction has certain properties that are collectively referred to as ACID properties.

ACID Properties of Transaction  Atomicity-all changes that a transaction makes to a database are made permanent; otherwise, all changes are rolled back.  Consistency-a successful transaction transforms a database from a previous valid state to a new valid state.  Isolation-changes that a transaction makes to a database are not visible to other operations until the transaction completes its work.  Durability-changes that a transaction makes to a database survive future system or media failures.

Uses of Transactions  Java Transactions is one of the most crucial requirements for enterprise application development in the domains of finance, banking and electronic commerce.  Online Document Processing  Regional Inventory Management Systems  In general, any application that involves sharing data among multiple distributed components.

Older Transaction Technologies  X/Open Distributed Transaction Processing Model

 Application Programs : implement transactional operations.  Resource Managers  Transaction Managers  Communication Resource Manager which facilitate interoperability between the different transaction managers in different transaction processing domains.

Some of the Interfaces implemented  TX Interface  XA Interface :This interface is used to support global transactions across different transaction manager domains via communication resource managers.  TXRPC Interface :interface provides portability for communication between application programs within a global transaction.

OMG Object Transaction Service  The OTS model is based on the X/Open DTP model with the following enhancements:  The OTS model replaces the functional XA and TX interfaces with CORBA IDL interfaces.IDL  The OTS is interoperable with X/Open DTP model.

OMG Object Transaction Service  Transaction Client  Transactional Object:A CORBA object that encapsulates or refers to persistent data, and whose behavior depends on whether or not its operations are invoked during a transaction.  Recoverable Object:A transactional object that directly maintains persistent data, and participates in transaction protocols  Transactional Server  Recoverable Server  Resource Object

Additional features of the CORBA OTS  Nested Transactions: This allows an application to create a transaction that is embedded in an existing transaction. In this model, multiple subtransactions can be embedded recursively in a transaction.  The main advantage of this model is that the application will have an opportunity to correct or compensate for failures at the subtransaction level, without actually attempting to commit the complete parent transaction.

 Application Synchronization: Using the OTS synchronization protocol, certain objects can be registered with the transaction service for notification before the start of and the completion of the two-phase commit process. This enables such application objects to synchronize transient state and data stored in persistent storage.two-phase commit

Java Transaction Initiative - Architecture  The Java transaction initiative consists of two specifications: Java Transaction Service (JTS) and Java Transaction API (JTA).  JTS specifies the implementation of a Java transaction manager.  The JTA specifies an architecture for building transactional application servers and defines a set of interfaces for various components of this architecture.

Java Transaction Initiative - Architecture JTA JTS Application Server Resource manager

Java Transaction Service (JTS) architecture:  The Java Transaction Service is architected around an application server and a transaction manager as shown in the next slide and consists of:  Transaction Manager: The transaction manager is the core component of this architecture and is provided by an implementation of the JTS.  Application Server: The application server abstracts all transactional semantics from the application programs.

Java Transaction Service (JTS) architecture:  Application Components: These are the clients for the transactional resources that implement business transactions and are deployed on the application server. Depending on the architecture of the application server, these components can directly or indirectly create transactions and operate on the transactional resources.  Resource Manager: A resource manager is an X/Open XA compliant component that manages a persistent and stable storage system.  Communication Resource Manager: allows the transaction manager to participate in transactions initiated by other transaction managers.

Java Transaction Service (JTS) architecture:

Some Useful Examples:  If: The client application needs to make invocations on several objects, which may involve write operations to one or more databases. The client application needs a conversation with an object managed by the server application, and the client application needs to make multiple invocations on a specific object instance. Within the scope of a single client invocation on an object, the object performs multiple edits to data in a database. If one of the edits fails, the object needs a mechanism to roll back all the edits.

Java Transaction API (JTA)

Packages : javax.transactionjavax.transaction  Provides the API that defines the contract between the transaction manager and the various parties involved in a distributed transaction ex : resource manager, application, and application server.  The UserTransaction interface can always be used in the following components:  Web components (JSPs and Servlets)  Session beans with bean-managed transactions enabled.

Interfaces implemented in javax.transaction  StatusThe Status interface defines static variables used for transaction status codes. Status  SynchronizationThe transaction manager provides a synchronization mechanism that allows involved parties to be notified before and after a transaction completes. Synchronization  TransactionThe Transaction interface allows operations to be performed against the transaction in the target Transaction object. Transaction  TransactionManagerThe TransactionManager interface defines the methods that allow an application server to manage transaction boundaries. TransactionManager  UserTransactionThe UserTransaction interface defines the methods that allow an application to explicitly manage transaction boundaries. UserTransaction

Packages cont’d  javax.transaction.xaProvides the API that defines the contract between the transaction manager and the resource manager, which allows the transaction manager to enlist and delist resource objects in JTA transactions. javax.transaction.xa

Interfaces in javax.transaction.xa  XAResourceThe XA Resource interface is a Java mapping of the industry standard XA interface based on the X/Open CAE Specification XAResource  XidThe Xid interface is a Java mapping of the X/Open transaction identifier XID structure. Xid

 XAExceptionThe XAException is thrown by the Resource Manager (RM) to inform the Transaction Manager of an error encountered by the involved transaction. XAException

Transaction Functions  begin() - Create a new transaction  commit() - Complete the current thread's transaction  rollback() - Abort the current thread's transaction  setRollbackOnly() - Ensure that the transaction must rollback

Code Sample  import javax.naming.*;  import javax.transaction.*;  import javax.sql.*;  import javax.ejb.*;  import javax.jms.*; import java.sql.*;

// This code fragment sits Inside a session bean. // The instance variable ctx represents a SessionContext. UserTransaction ut =ctx.getUserTransaction(); ut.begin();

// Each of these environment entries is arbitrarily named and would be set in the EJB's // deployment descriptor, and set up in the J2EE server's administration tool. DataSource ds1 = (DataSource) ic.lookup("java:comp/env/jdbc/DatabaseOne"); DataSource ds2 = (DataSource) ic.lookup("java:comp/env/jdbc/DatabaseTwo"); QueueConnectionFactory qcf = (QueueConnectionFactory) ic.lookup("java:comp/env/jms/JMSQ");

try { // perform work with the three resources ut.commit(); } catch (Exception e) { ut.rollback(); } finally { // close resources }

References:  les/jts/JTS.html les/jts/JTS.html  jta/gstrx.html# jta/gstrx.html#  s/article.tss?l=Nuts-and-Bolts-of- Transaction-Processing s/article.tss?l=Nuts-and-Bolts-of- Transaction-Processing  doc/index.html doc/index.html

Reference cont’d  ibm.com/developerworks/java/lib rary/j-jtp0305.html ibm.com/developerworks/java/lib rary/j-jtp0305.html  rticleAction.aspx?articleID=77 rticleAction.aspx?articleID=77

QUESTIONS ????

Session Bean  A session bean is a type of enterprise bean; a type of EJB server-side component. Session bean components implement the javax.ejb.SessionBean interface and can be stateless or stateful. Stateless session beans are components that perform transient services; stateful session beans are components that are dedicated to one client and act as a server-side extension of that client.

 A smart component could check on the current status of the transaction and potentially save resources by not performing work that would be lost anyway. This would involve calling UserTransaction.getStatus(), which returns an int constant defined on the javax.transaction.Status interface:  STATUS_ACTIVE - A transaction is active.  STATUS_COMMITTED - The last active transaction was committed.  STATUS_COMMITTING - The last active transaction is committing.  STATUS_MARKED_ROLLBACK - Marked for rollback, perhaps by setRollbackOnly()

 STATUS_NO_TRANSACTION - No transaction is active  STATUS_PREPARED - A two-phase commit finished the prepared (1st) phase.  STATUS_PREPARING - A two-phase commit is inside the prepared phase.  STATUS_ROLLEDBACK - The last active transaction was aborted.  STATUS_ROLLING_BACK - The last active transaction is aborting.  STATUS_UNKNOWN - The transaction manager has no idea. (Try again later.)

Java Transaction APIs architecture: JTA

 In computing, Common Object Request Broker Architecture (CORBA) is a standard for software componentry, created and controlled by the Object Management Group (OMG). It defines APIs, communication protocol, and object/service information models to enable heterogeneous applications written in various languages running on various platforms to interoperate. CORBA therefore provides platform and location transparency for sharing well-defined objects across a distributed computing platform.software componentryObject Management GroupAPIsapplicationslanguagesdistributed computing  In a general sense CORBA “wraps” code written in some language into a bundle containing additional information on the capabilities of the code inside, and how to call it. The resulting wrapped objects can then be called from other programs (or CORBA objects) over the network. In this sense, CORBA can be considered as a machine- readable documentation format, similar to a header file but with considerably more information.programs objectsnetworkmachine- readableheader file  CORBA uses an interface definition language (IDL) to specify the interfaces that objects will present to the world. CORBA then specifies a “mapping” from IDL to a specific implementation language like C++ or Java. This mapping precisely describes how the CORBA data types are to be used in both client and server implementations. Standard mappings exist for Ada, C, C++, Lisp, Smalltalk, Java, and Python. There are also non- standard mappings for Perl and Tcl implemented by ORBs written for those languages.interface definition languageC++Javadata typesAdaCC++LispSmalltalkJavaPythonPerlTclORBs  The CORBA IDL is only one example of an IDL.