Search SOA - WS Transactions
Search SOA - WS Transactions
Search SOA - WS Transactions
OASIS has formed a committee to ratify a family of Web services transactions standards, paving
the way for service-oriented architectures to do more actual business in the future.
The proposed standards are WS-Coordination, which creates the framework for a transaction,
and WS-AtomicTransaction (WS-AT) and WS-BusinessActivity (WS-BA), which enable short- and
long-duration transactions. The standards come to OASIS in fairly solid shape, with
interoperability tests already having been run on them.
Though the first meeting of the standards committee isn't until mid-November, proposed co-
chair Ian Robinson, a transaction architect for IBM's WebSphere Application Server, believes
WS-Coordination can be ratified within six months with the other two to follow six months
later.
"It is quite aggressive, but I think it's realistic," he said. "Based on our
experience with testing, we know these specifications can work. Our
expectation is that this will mostly involve refinement."
"People do transactions over the Web all the time, but those tend to be
single database transactions," he said.
These standards will attempt to create the mechanism through which a more detailed and
complex business relationship can be executed. Newcomer envisions everything from multi-
phase supply chain transactions to distributed online shopping carts.
"I think everybody saw where it was going early on in the dot-com days, but it's taken a while to
get there," he said.
Though WS-Coordination is the first spec in line for approval, Robinson called it "perhaps the
hardest to understand."
It defines how a service gets activated and registered, after that the WS-AT and WS-BA will take
care of how the transaction gets processed.
While breaking out of the proprietary transaction model may be a powerful idea, Robinson
touted WS-BA as the specification with the greatest long-term potential.
"It's designed to allow these new types of transactions we're trying to build with Web services,"
he said. "You could take two different BPEL [Business Process Execution Language] processes
and come to a joint consensual agreement between them."
As with all other Web services standards, the transaction family will be designed to
interoperate with other specifications, such as those concerning security, addressing and
reliable messaging.
Chris Kurt, director of Web services standards for Microsoft, said layering and dependencies are
part and parcel of how businesses will customize the standards to fit their individual needs.
"Folks that are adopting Web services will be able to combine them in pretty much any
reasonable way," he said.
When it comes to transaction management, the key limitation in many Web services-based
implementations is performing cross-service transactions. As long as a service is at the root of a
transaction and the scope of the transaction is limited to activities that are performed by the service's
underlying solution logic, there is no need for cross-service transaction functionality, and the transaction
can be managed by whatever proprietary technology (component-based, legacy, or otherwise) it
encapsulates. However, as the amount of services in an environment grows, the need to span
transactions across those services increases. To address this requirement a set of WS-* specifications
were developed a while ago.
These protocols dictate the terms of the activity. WS-AtomicTransaction, for example, provides
protocols for ACID-type transactions with two-phase capability. WS-BusinessActivity provides protocols
for long-running transactions with compensation processes (as opposed to a rollback). Adoption of these
specifications has been slow and gradual. They are expected to become increasingly important in the
next 1-2 years. Microsoft's Indigo, for example, has already been promoted as supporting WS-
AtomicTransaction.
WS-Coordination
WS-AtomicTransaction
WS-BusinessActivity
The standards were created to accommodate two typical transaction patterns involving
multiple, distributed software components and services:
1. individual atomic transactions that represent the building blocks for more complex
transactions among peers and partners
2. Web-based interactions that result in the exchange of goods, information, or services,
usually called business activities.
WS-coordination refers to the mechanisms whereby atomic transactions may be composed into
complete business activities, and thus also provides the glue that ties the overall WSTx
environment together.
WSTx standards are overseen by a technical committee of the same name at OASIS (the
Organization for the Advancement of Structured Information Standards). The technical
committee is staffed with vendors and users of Web Services technologies. On its Web pages,
the committee describes its agenda as: "…to define a set of protocols to coordinate the
outcomes of distributed application actions." Vendors involved in the WSTx committee include
Adobe, BEA Systems, Fujitsu, Hitachi, IBM, Microsoft, Oracle, SAP and TIBCO, among numerous
others.
The importance of dealing appropriately with transactions in Web services arises from the same
cross-platform manner in which Web services operate. Since transactions offer an "all or
nothing" contract for executing a unit of work, bridging the disparities that might exist between
platform specific transaction mechanisms is a necessity in many SOAP-based applications.
Take the Java platform, while JTA (Java Transaction API) provides extensive support for dealing
with many transaction scenarios within Java applications, as soon as transaction integrity is
required outside the boundaries of any non-Java applications -- such as .NET or PHP --
transaction support generally entails ad-hoc techniques with very strict limitations.
Web services, being a technology used to bridge disparate platforms, has a series of
specifications designed to deal with the intricacies of transactions.
Developed by heavyweight industry players like IBM, BEA and Microsoft, Web services
transactions specifications are currently split into three major working groups: WS-
Coordination, WS-Atomic Transaction and WS-Business Activity.
WS-Coordination defines the underlying foundations for any transactional process taking place
between Web services. Used in conjunction with either WS-Atomic Transaction or WS-Business
Activity, WS-Coordination is used to define the mechanism by which Web services register and
coordinate themselves to take part in a transaction.
WS-Atomic Transaction is actually closely pegged to an existing and widely known protocol in
enterprise software: the two-phase commit protocol. While delving into details of this protocol
would go beyond the scope of Web services, the basics behind its operation consist of
synchronizing an all or nothing task between two resources in order to ensure a consistent
outcome.
Generally speaking, the use of a two-phase commit, and hence WS-Atomic Transaction, centers
around short-lived operations, or in other words, processes were the success or failure of a
transaction is needed to be known rapidly.
WS-Business Activity on the other hand is designed with longer running transactions in mind.
The other major difference being the robustness with which it can handle transactional
scenarios when compared to WS-Atomic Transaction.
While WS-Atomic Transaction provides an all or nothing solution to transactions -- either
success or failure -- WS-Business Activity has provisions for such things as exception handling
with the capacity to execute compensatory tasks.
Now that we have covered the conceptual part of Web services transactions, you may be asking
yourself how to put transactions together in real world Web services applications. For this, like
any other specification, you need an implementation and one such project isKandula , produced
by the Apache Software Foundation.
Being an Apache project, the transactional facilities in Kandula are closely pegged to Axis, which
is the de-facto Web services platform developed by Apache. Since this last project is focused on
Java, the WS-* transaction support in Kandula plays into Java transactional facilities.
The simplest manner to exemplify the use of Kandula is observing a code snippet, listing 1.1
illustrates what a Web services class using Kandula WS-Atomic Transaction would look like.
import org.apache.kandula.coordinator.at.TransactionManagerImpl;
By nesting in this manner, Kandula via Axis is propagating transactional information to the
Inventory class that is later wrapped in the corresponding SOAP payload for later consumption
and coordination by the service end points.
While transactions are often an afterthought for many software projects, when the need arises
to manage them explicitly they provide a critical role in fulfilling a software's business functions.
The specifications we just covered provide this pivotal role in the still emerging world of
service-oriented architecture.
WS-AtomicTransaction (WS-AT)
WS-AtomicTransaction (WS-AT) is a protocol for managing atomic transactions between
distributed applications, transaction managers and resource managers. An atomic transaction is
a single, irreducible component of a classic transaction, such as making a purchase. WS-AT
ensures that if a single atomic transaction fails, the whole transaction fails: A partial transaction
cannot take place. For example, if a customer is transfering funds from one account to another,
WS-AT makes it impossible for funds to be removed from one account successfully but not
deposited into the target account.
There are multiple atomic transactions within most classical transactions. For example, when a
consumer makes a retail purchase using a credit card, several steps are involved: ringing up the
sale, swiping the card through a reader, verifying the validity of the account associated with the
card, ensuring that the account has sufficient available credit and producing a receipt. Each of
these components is an atomic transaction. In combination, they constitute a classical
transaction.
We are publishing certain interfaces through Web services. The Web service performs one unit
of work. There are scenarios where the client can have this Web service participating in a
transaction originating in the client. The problem is this: The clients are able to rollback or
execute updates via other non Web service components, but they are not able to do so with
those done via the Web service. The Web service and the client are all implemented in .NET. I
have read the WS-AtomicTransaction specification but have struggled to find a framework
which supports it.
Have you faced such a problem and if so, can you please share your experience and
recommend a framework that will support this specification?
What you are looking for is Indigo, the next generation of .NET. Indigo will provide a service-
oriented programming model that encapsulates the process of promoting transactions from
lightweight transactions that do not require the Distributed Transaction Coordinator (DTC), to
DTC-enabled transactions that support cross process and distributed .NET components, to Web
service transactions that require WS-AtomicTransaction. All of this will be done through a
similar declarative (implicit) programming model as is done today with EnterpriseServices
in .NET 1.1. An explicit programming model will also be available for greater control. Today,
in .NET 2.0, a transitional set of functionality is already available. The Lightweight Transaction
Manager (LTM) will automatically promote to DTC transactions when more than one Resource
Manager is participates in a transaction, for example.
For more information on 2.0 transactions with a 1.x backgrounder, read my colleague Juval
Lowy's white paper.
So, what can you do today? Sigh. Roll your own I'm afraid. In my opinion you are in for a long
road if you try to implement your own plumbing for the WS-Coordination (WS-COOR) and WS-
AtomicTransaction (WS-AT) protocol. You're better off waiting, and taking the plumbing for
free. Mind you the specifications for WS-Coordination and WS-AtomicTransactions although far
along, are not yet ratified. By the time platform support is available on the .NET and Java side
they should be. They will handle all of the state management and XML serialization
requirements for incorporating a service operation into a transaction, and you can work as you
do today, applying declarative transaction attributes to the operation.
I should also mention that on the Java side, there are a few vendor platforms that include
implementations for WS-COOR and WS-AT, they are:
These won't help you with your .NET services obviously, but it is at least interesting that there
are vendors out there that have begun to support these standards even in their interim state.
More specifically, WS-Policy delivers a flexible, extensible grammar for assertions regarding the
capabilities, requirements, and general characteristics in a specific XML Web services based
system. WS-Policy allows such properties to be stated as policies, which may be simple
declarative assertions but may also be more complex conditional declarations. In this context, a
policy consists of one or more policy assertions and may include such things as authentication
schemes, transport protocol selection, privacy policy, QoS characteristics, and more.
SOAP W3C Defines the XML message format for Web services.
UDDI OASIS Provides a method for publishing the access information for a
Web service.
As Web services have gotten more complicated, communication between potential client and
service has become more difficult and early attempts such as WSDL have not always been up to
the task of completely defining the requirements. Typically developers fall back on text
documentation, discussions on user mailing lists or calling a more knowledgeable person to
resolve a problem.
What is WS-Policy?
The Web Services Policy Framework (or WS-Policy for short) is intended to provide a basic
general purpose model and XML syntax for describing policies related to a Web service. Policies
can be defined, not only for a given Web service, but also by potential clients of the service. For
example, your company might require that developers only access Web services using digital
signatures. WS-Policy functions as an addition to WSDL, UDDI and other WS-* specifications.
A WS-Policy document expresses rules that may be as simple as a requirement to use WS-
Addressing in SOAP headers or as complex as giving a list of "assertions" about alternate
message signing algorithms which the service can recognize. Essentially, WS-Policy attempts to
formalize in both machine- and human-readable form aspects of Web service communication
that might otherwise require extensive text documentation or direct person to person
communication. The examples given by the WS-Policy working group show how to express
complex security requirements.
The WS-Policy specification has undergone a series of drafts and is now at the "Last Call
Working Draft" stage, but does not yet have official W3C status. You can get a copy of the
current working draft documentation from the Web Services Policy Working Group URL given in
the resources.
Creators of WS-Policy
The list of participants working on WS-Policy shows that a wide spectrum of industry
heavyweights have been contributing to the process of refining the framework. As part of the
W3C's recent emphasis on software patent policy, these companies have made licensing
commitments to ensure that when WS-Policy reaches Recommendation stage it will be royalty
free.
The basic WS-Policy specification does not state how a given policy document gets associated
with a specific Web service. That function is being covered in a separate WS-PolicyAttachement
specification that defines mechanisms by which a policy gets associated with a Web service
entity and with WSDL or UDDI descriptions.
Implementations
Microsoft provides the Web Services Enhancements add-on for Visual Studio.NET which
supports WS-Policy and many other of the latest Web services related specifications.
The Apache "Commons" open source project contains a set of Java classes for reading and
manipulating WS-Policy documents. This toolkit is part of the new Apache Axis2 Web services
toolkit, but not part of Sun's Java Web Services Developer Package. The Apache API includes the
rather elegant capability of automatically combining a WS-Policy document for a service with
potential client policy alternatives to reveal the policy or policies where there is mutual
agreement.
Conclusion
For me the question is - will WS-policy prove to be the solution to the obvious problem of
helping developers coordinate all of the various specifications related to Web services or will it
join the ranks of elegant specifications that everybody admires but few people use? Check back
again in a year, maybe we will know by then.
In the absence of high-end data integration tools, like IBM's WBI (WebSphere Business
Integrator) or BEA's WLI (Weblogic Integrator), you may need to consider a programmatic-
intensive solution for distributed transactions and/or moving data at the application-level.
The following system use cases for implementing distributed transactions have been identified:
Bean-managed transactions - the code in the application explicitly marks and manages the
boundaries of the distributed transaction.
Container-managed XA-style transactions – the container manages the transaction and
relies on the XA protocol and two-phase commits for coordinating the distributed
transaction.
Web services transactions – use WS-COOR, a basic coordination mechanism on which
protocols are layered, and WS-AT, a classic two-phase commit protocol.
In practice, the first two approaches are really more appropriate for enterprise-wide type
integration; whereas, the last construct could be used over the Internet for B-to-B type
integration, if you consider your organization to be a cutting-edge adopter of technology.
Given the finite set of alternatives for distributed transaction processing, this discussion
attempts to define why XA has been and will remain a key component within enterprise-wide
systems reference architecture, until a completely new paradigm for managing distributed
transactions is invented.
Figure 1 - Moving data between two databases and a JMS message within a tightly coupled
workflow
Although, using an EJB for Bean-managed transactions is not strongly recommended, since one
of the reasons you use an EJB is to provide container-managed transactions for XA or non-XA-
style transactions. With XA in place, an EJB can manage a transaction that spans multiple XA-
compliant resources and treats those resources, essentially as a single resource. If you aren't
using EJB in this fashion, it probably isn't worth using at all.
For Java EE applications, a container-managed EJB is the best construct for implementing an XA-
style transaction. It essentially is performing the same fundamental operations as the Bean-
managed EJB. However, the container manages all transaction instructions and, in the event of
a failure, the Java Transaction Service (JTS) will roll back all of the participating resources. From
a programmer perspective, this solution still represents the simplest approach to implementing
distributed transactions, even compared to Web services as we will soon see.
At a high-level, WS-AT is designed so you can include two or more Web services into the same
transaction. WS-AT provides the ability for your Web service applications to participate in global
transactions. For example, you have Web service one (a Microsoft-bound Web service) and
Web service two (a Solaris-bound Web service) and you can coordinate and manage the
services as a single logical unit of work, similar to an XA-style transaction.
XA is not really the same thing as WS-AT, since it's the interface between the transaction
manager and the resource manager. And, it is important to point out, that XA is not a remote
protocol. However, the fundamental result is the same, that is, the transaction is coordinated
among disparate resources.
Essentially, WS-AT's responsibility is to manage the distributed the transaction between your
Web service applications, while the JTS takes care of registering the XA resources that are
participating in the global transaction. When evaluating WS-AT, the complexity of "managing
the distributed transaction between Web services," in my mind's eye, appears to be the most
daunting part of using the technology.
The sequence diagram below focuses on the coordination and registration process when using
a WS-AT style transaction. The model represents the database operations depicted in Figure 1
exposed as Web services. The basic Web flow is:
Note: the diagram is a high-level representation of a two-phase commit use case scenario,
based on my understanding of the WS-AT and WS-COOR specs. Web service N is a logical
realization of the transaction in that the transaction can span multiple XA-compliant resource
(JMS, D2, Oracle, SQL Server, etc.)
WS-TX implementations
Currently, WS-TX implementations are available from IONA Technologies, IBM, Microsoft, Red
Hat (i.e. JBoss) and Choreology (a small UK company). In addition, Sun will release a version
soon, if they haven't already. Oracle and BEA participated in the development of the standard
and are expected to also have their own implementations of the specs.
SOAP-based and WS-* specifications are designed to work together to define a rich Web
services (transaction) environment. WS-AT by itself does not define all features required for a
complete solution. WS-AT is considered a building block used with other specifications of Web
services (e.g., WS-Coordination, WS-Policy, WS-Security, etc.) and application-specific protocols
that are able to accommodate a wide variety of coordination protocols related to the
coordination actions of distributed applications.
WS-AT is a two-phase commit transaction protocol and is suitable for short duration
transactions only. Application servers that implement the WS-AT specification, enabling the
Web services application to participate in global transactions distributed across a
heterogeneous Web services environment. As a transaction manager, the application server
supports the coordination of resource managers through their XAResource interfaces and
participates in distributed global transactions with transaction managers that support WS-AT.
The expected best practice is to use WS-AT within a single enterprise, avoiding WS-AT usage
across enterprise domains. The application server runtime takes responsibility for registering
WS-AT participants in the same way as XA resources are registered in the JTAtransaction to
which the WS-AT transaction is federated.
Implications
In keeping with the spirit of Web services as interfaces to existing implementations, the WS-AT
and WS-COOR specification author's design exposes XA. As a consequence, organizations that in
the past have had issues with supporting XA will also have issues with supporting this new
technology, which adds a layer of abstraction and complexity in addition to XA. Although, it
seems that Web services and SOA have enjoyed, so far, a certain cache that XA never had and
organizations will probably go through the necessary hurdles in order to support it.
"Enterprise service buses are the preferred tools for integrating systems with
heterogeneous data interchange interfaces and based on a wide array of technologies, from
COBOL to CORBA to JEE". (Eugene Ciurana, Mule: A Case Study, TheServerSide.com)
While Web services are clearly useful for integration with heterogeneous data sources, relying
solely on Web services, especially for heterogeneous (that is, distributed) transactions is more
complex than supporting XA and architecturally limiting. Furthermore, the Web services
specifications and resulting implementations are new, and therefore not as mature as XA. If
Web services are pursued, a number of other WS-* specifications would need to be in place to
begin to construct the transactional management that XA provides.
Still, I agree with Dan Foody, CTO of Actional in that "The long term success of Web services and
SOA is directly affected by their ability to be used for mission critical solutions in the enterprise.
Because many mission critical applications require transactional integrity, WS-TX (Web Services
Transaction) will enable these applications to be successfully built and deployed using Web
services without sacrificing multi-vendor interoperability."
For the most part, all business software systems are derived from corporate processing
requirements. Even the modern concept of an "enterprise service bus" I am sure was
developed within a PowerPoint presentation of a senior business analyst in order to address
the dysfunctional enterprise environment after a merger and acquisition.
Still, business process analysts should not be encumbered by the technological feat of a process
design during the visioning stage of a new application, even if the requirements indicate the
need for heterogeneous transactions between legacy applications. After all, that is what XA is
all about.
These integration points are at the individual claim transaction level, so internal consistence of
workflow transactions is paramount to the overall "enterprise-wide" system staying internally
consistent. Based on these requirements and the specified logical units of work (see figures:
Logical Unit of Work 1 and 2), it became clear to me that the best way to guarantee transaction
integrity was to develop a set of XA-style transactions. While some analysts suggest that a set of
Web services could accomplish the same object, there are limitations to using that construct,
which will be further discussed.
The XA interface is a mature protocol for treating DB2, Oracle and JMS (an XA-compliant
interface to a physical queue) as essentially one resource, where logical transactions can be
committed and rolled back. Using an XA-style transaction, the programmer does not need to be
concerned with handwriting defensive, compensating transaction code, which is by nature error
prone, in the event of unknown application-bound SQLExceptions or Java runtime exceptions.
The programmer, because of the enabling XA technology, can focus more on simply creating
the atomic transaction code, let the XA resource manager handle rollback and commit logic.
Without XA, the programmer needs to find a creative solution to rolling back the distributed
transaction in case one of the participating resources fails, instead of a standard mechanism.
Alternatively, the programmer might develop an optimistic construct and assume that his code
will never fail, and it may not … until he/she leaves the project.
High-end JEE application servers, such as, Oracle Application Server, WebLogic and WebSphere
support JTA (Java Transaction API) required for XA style transactions. An XA transaction involves
coordination among the various resource managers, which is the responsibility of the
transaction manager.
The transaction manager is responsible for making the final decision either to commit or
rollback any distributed transaction. JTA specifies standard Java interfaces between the
transaction manager and the application server and the resource managers.
All XA-compliant transactions are distributed transactions. XA supports both single-phase and
two-phase commit. A distributed transaction is a transaction between two or more
independent transactional resources (for example, two separate databases). For the transaction
to commit successfully all of the individual resources must commit successfully; if any of them
are unsuccessful, the transaction must roll back in all of the resources.
I first used XA on a large-scale DCE (Distributed Computing Environment) project with a major
NYC bank where we used Transarc's Encina Transaction C++ (now an IBM company). This was in
the middle '90s and XA was already established and one of the key protocols within the DCE.
After all, if you are going to call yourself the "distributed computing environment" you better
support distributed transactions.
XA, then and even now has a reputation for being slow, mainly because of the complex prepare
and commit transaction lifecycle among disparate resources coordinated by the transaction
manager. Although, considering the alternatives, it remains an important tool in the integration
architect's toolbox. Indeed, XA outside the banking industry still appears to be an unknown or
at least a little-used protocol.
If your organization doesn't have a high-end data integration tool, you may need to develop
custom distributed transactions applications. Here is a short list of reasons for using XA:
Moving data between a database and a JMS message within a tightly coupled workflow --
An application may need to move data from a database to another database and then send
a JMS message to another disparate system or a message-driven bean that indicates the
new data has arrived (see figure below).
Moving data between disparate databases as a transaction hand-off -- Moving data from
one database to another requires an XA-style transaction or a normal transaction that
includes a compensating transaction in the event of a failure. For example, the insert
completes and the update fails (see figure below).
A compensating transaction can take the form of a delete operation or a forced rollback. For
example, for bean-managed transactions, an update, although successful, can be rolled back if
the insert operation fails (see Logical Unit of Work 2) in order to keep the application workflow
internally consistent.
Alternatively, for Logical Unit of Work 1, if the JMS send fails, the application construct can be
built to be idempotent. That is, if the send operation fails it can be "repeated safely" maybe not
immediately, because a failure might indicate that the resource is in an inconsistent state, but
at some future time. Again, the application workflow will remain internally consistent. As a
colleague of mine once cautioned, maintaining state in a distributed environment is an evil
thing.
The point here is not that designing and developing compensating constructs is necessarily
complicated. It is that in the absence of XA, non-standard and sometimes very unique strategies
need to be devised for each distributed action failure, instead of letting the XA protocol and
underlying resource manager manage the transaction. Essentially, the programmer has a
standard mechanism for managing distributed transactions.
Today some technologists are even positioning the enterprise service bus (ESB) as a standard
mechanism for integrating systems with heterogeneous data interfaces. While ESB and Web
services can clearly be used to move data between disparate data sources, I would not
recommend using a set of Web services to implement a distributed transaction if the
transaction requirements could be achieved by using XA, even if the enabling Web services
technology supported WS-Transaction (WS-TX). The one advantage Web services have over XA
is that XA is not a remote protocol, though.
WS-Transaction is the name of the OASIS group that is currently working on the transaction
management specification. WS-TX is the name of the committee, and they are working on three
specs:
I recently spoke with a senior member of the OASIS WS-TX committee from Oracle while
researching this article regarding the robustness of WS-AT versus XA. He clearly indicated that
while the technology was similar, testing at Oracle was problematic in certain system use case
scenarios. This discussion has further corroborated my opinion that in the near future, if a
distributed transaction is warranted, I will rely on XA rather that an immature, albeit, modern
solution.
Of interest to the Open Source and Java communities, MySQL 5.0 now has distributed
transaction processing support through XA. Additionally, FirstSQL/J Enterprise Server has
comprehensive support for connection pooling and Java Transaction APIs (JTA) for distributed
transaction (that is, XA) capabilities.
Implications
Truth be told, XA is viewed as a luxury and not a "required" application tool for programmers
within most organizations. However, infrastructure groups that don't support XA are essentially
establishing an asymmetrical transaction failure risk curve that is skewed against the
application programmer.