|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
General Java Interfacing Transaction Services: Part 2
Interfacing Transaction Services: Part 2
By: Maros Cunderlik
Jul. 1, 1998 12:00 AM
Undoubtedly, the support for distributed transactions is a part of any enterprise system. Part One of this series (JDJ, March 1998) explored the X/Open Distributed Transaction Processing (DTP) Model - a common model for distributed transaction processing. We also explained the concepts of Microsoft Transaction Server (MTS) that quickly become de facto standard for developing business components on the Windows platform. We demonstrated how to write "first-class" MTS COM components in Java. The described process of creating these components has been greatly simplified by the release of Microsoft Visual J++ 6.0. In this second part we will take a closer look at CORBA Object Transaction Service (OTS). As Java gains wider acceptance in enterprise computing, we are likely to see a number of simplified object models and API layers that will rely on OTS to provide transaction support (e.g., EJB, Java Transaction Service, IBM's San Francisco Project, etc.). These models greatly reduce the amount of code necessary to create applications with full transaction support. Nevertheless, as the number of components in the system increases, the complexities of real-world systems are often encountered. These include managing object interdependencies, state and context management, and dealing with various hardware and network limitations. To make the situation worse, the problems often go undetected until the deployment time because of insufficient prototype evaluation and stress testing. In solving these issues, an understanding of the underlying CORBA specification and implementations is critical. Therefore, we will describe in this article the fundamentals of CORBA OTS specification as defined by Object Management Group (OMG). We will also show some details of CORBA OTS commercial implementations and discuss the relationship between CORBA OTS and EJB. CORBA Object Transaction Service Specification CORBA OTS specification is loosely based on X/Open DTP Model. The specification defines a model that complies with ACID transaction properties: atomicity, consistency, isolation and durability. The specification also describes the set of standard interfaces and behaviors that define how a client, the Transaction Service and the transactional objects participate in transaction processing. Figure 1 illustrates the main entities of CORBA OTS.
In simple view, the client starts a transaction by contacting the Transaction Service. The service creates a transaction context for the new transaction. The client then makes a series of requests on transactional and nontransactional objects. The transactional objects that maintain durable data and state are called recoverable objects. These objects must register with the Transaction Service using a resource object. The resource object participates in coordinating a two-phase commit process, and is used to access the underlying resources consumed by the objects. When finished, the client commits or rolls back the changes by instructing the Transactional Service to commit or roll back, respectively. The service then coordinates the two-phase commit process with all resources registered within the scope of the current transaction. Listing 1 shows the definitions of all OTS-defined data types and interfaces in Interface Definition Language (IDL).The CORBA OTS specification defines two basic approaches to carrying out transaction processing. These are based on the level of involvement in the context management and transaction propagation. The context management refers to the process of the transaction context creation, initialization and control. In general, the participants can choose the indirect context management and rely on the Transaction Service to perform all context-related responsibilities. On the other hand, the client can elect to manage the transaction context directly by using the set of standard OTS interfaces. Similarly, when creating transactional objects, the client can use the Transaction Service implicit propagation, or explicitly pass the transaction context to the objects. Clearly, there are four possible combinations of how to perform the context management and transaction propagation: While all of these combinations are valid, the ones described in the following sections are the most common. These two combinations reflect the fundamental design tradeoff between ease of use and flexibility.
Indirect Context Management and Implicit Transaction Propagation At the client's request, the Transaction Service commits the changes through the two-phase commit process with all registered resources. When the client requests to commit the transaction, the Coordinator issues the Resource.prepare() command. The resources then prepare to commit and return the Vote object accordingly: VoteCommit, VoteRollback or VoteReadOnly. The VoteReadOnly indicates that no changes were made to the underlying persistent data managed by the resource. If all registered resources voted VoteReadOnly, the Coordinator informs the client about the successful commit. If at least one resource replied VoteCommit and the rest of the registered resources voted VoteReadOnly, the Coordinator first saves the current transaction information in case of later failure, and then completes the two-phase commit process by calling Resource.commit().
Direct Context Management and Explicit Transaction Propagation The server objects do not have to implement TransactionalObject interface. Instead, these objects receive the reference to the Control object as an explicit parameter for each method. This allows the same object to have both transactional and nontransactional methods. All transactional methods must use the passed-in Control object to retrieve the reference to the Coordinator object and register all their resources. Figure 3 illustrates how the client and the recoverable server engage in transaction processing using the direct context management and explicit transaction propagation.
Nested Transactions and X/Open Interoperability The specification also establishes guidelines for integrating with X/Open compliant systems. In particular, transactions can be imported and exported across the two models. The OTS implementations should allow XA-compliant resource managers to participate directly in OTS transactions. The OTS specification explicitly allows a single transaction service to support both X/Open DTP and OTS models. This decision not to engage in "purist" arguments will certainly prove critical to the specification's success with vendors and customers. The transaction monitor vendors can leverage their experience with X/Open and incrementally add OTS support onto the existing products (e.g., IBM TXSeries Transaction Server). On the other hand, users can easily integrate their "legacy" systems with the new CORBA-compliant applications.
CORBA OTS Implementations On the Java side, OMG provides a standard Java mapping of IDL data types, modules and other constructs. It also offers details on server-side mapping of transient and persistent objects, Java ORB portability and mapping of CORBA pseudo objects into Java. JDK 1.2 contains a great example of this mapping -- an implementation of CORBA 2.0-compliant ORB and CORBA Naming service. In addition to JDK 1.2, the release of the Java Transaction Service (JTS) and Enterprise JavaBeans (EJB) specifications further strengthened the bond between CORBA and Java. These technologies also helped to clear up some of the confusion over the relationship of CORBA and the Java platform. EJB was designed to provide a high-level component architecture for writing business applications. In general, the enterprise bean object can use automatic declarative transaction management by specifying a transaction attribute. The bean container interposes all client requests, and the container is then responsible for managing the transaction according to the transaction attribute. EJB defines valid values for the bean transaction attribute (TX_NOT_SUPPORTED, TX_BEAN_MANAGED, TX_REQUIRED, TX_SUPPORTS, and TX_REQUIRES_NEW) that are very similar to Microsoft MTS transaction attributes. For example, the bean marked TX_ REQUIRED will execute in the client's transaction context, if the client has one. Otherwise, the new transaction is automatically created. The bean can also choose to use manual transaction management by specifying TX_BEAN_MANAGED attribute. Under this scenario, the clients and the beans use the JTS javax.jts.UserTransaction interface (see Listing 2) to directly manage the transaction. In fact, UserTransaction interface is the only JTS interface that the bean container must provide to be EJB compliant. The JTS specification defines a standard transaction management API for the Java platform. It includes org.omg.CosTransactions and org.omg.CosTSPortability packages that contain the standard Java mapping of the CORBA OTS modules. As mentioned before, the JTS also defines a high-level application transaction "demarcation" API (javax.jts package). Since this API provides an isolation layer between the enterprise beans and the service implementation, in theory any transaction manager exposing this API can participate in the EJB model.
Conclusion The CORBA Object Transaction Service offers an alternative model for two-phase commit transactions. The OTS specification describes how the clients, transactional objects, resources and the OTS participate in transaction creation, context management, transaction propagation and two-phase commit protocol. In addition to the flat transaction model, the Transaction Service provides support for nested transactions. While a variety of OTS commercial implementations are available, their success will often be determined by features like transaction monitor, CORBA server management and productivity tools, and ease of integration with "legacy" X/Open DTP-based applications. With the release of JDK 1.2, Java Transaction Service and Enterprise JavaBeans specifications, CORBA and Java platform integration has never been better. EJB provides necessary higher-level abstractions for creating business components in Java. At the same time, EJB relies on technologies like CORBA to provide the underlying service implementation. As a result, understanding of CORBA, CORBAservices and CORBA OTS in particular will prove to be essential for building large business systems in Java.
References and Resources Reader Feedback: Page 1 of 1
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
|||||||||||||||||||||||||||||||||||||||||||||||||