Introducing WS-CAF - More than just transactions
Introducing WS-CAF - More than just transactions
Dec. 1, 2003 12:00 AM
Web services have become the integration platform of choice for enterprise applications. Those applications by the very nature of their enterprise-scale components can be complex in structure, which is compounded by the need to share common data or context across business processes supported by those applications. Those processes may be very long lived, and may contain periods of inactivity, for example, where constituent services require user interactions.
In response to these issues, WSCAF (Web Services Composite Application Framework) was publicly released in July 2003 after almost two years of effort, and has broad industry support from companies such as Iona, Oracle, Sun, and a host of others, and is now under the care of an OASIS standardization effort through the WS-CAF Technical Committee. The WS-CAF specifications are a suite of protocols designed to provide the necessary framework for composing Web services into larger aggregate business processes. Given that WS-CAF is the first framework of its kind to make its way into standardization, it's important to understand the principles underpinning it.
This article provides a high-level view of WS-CAF starting from the bottom up, explaining the layered architecture of the trio of specifications that comprise WS-CAF, and demonstrating how each of the specifications can be used in its own right or as a whole to provide a rich framework for building reliable composite applications.
The purpose of a context is to allow multiple individual Web services to enter a relationship by sharing certain common attributes as an externally modeled entity. Typical reasons for Web services to share context include common security domains where multiple Web services execute within the scope of a single authorized session, or common outcome negotiation where each party within the activity needs to know whether each of the other participants successfully completed his or her work.
The structure of a context is application specific (as we shall see, WS-CoordinationFramework and WS-TransactionManagement both extend the basic WSContext context for their own purposes), but contains at a minimum a unique ID in the form of a URI. Web services are identified as participants in the activity by including the context in an application message's SOAP header block (see Listing 1).
In general terms, a context defines basic information about the activity structure. It contains information necessary for multiple Web services to be associated with the same activity, which may be dynamically updated by services as the application or process makes progress. Activities are managed by the context service, which maintains a repository of shared contexts associated with execution environments. Whenever messages are exchanged within the scope of an activity, the context service can supply the associated context, which may then be propagated with those messages. The Context Service also manages hierarchies of contexts to support nesting and concurrency.
As we have seen, the core context propagation framework provides a generic context structure that enables an activity to be uniquely identified so that work can be correlated. Additionally, it supports application- and service-specific extensions to the context, structure. To facilitate this, the context consists of:
In addition to the context service, each Web service participating in an activity may register an Activity Lifecycle Service (or ALS) with the Context Service, which allows that service to be informed about the lifetime of the context. As we shall see, the ALS is the key component in utilizing WS-Context as the base protocol for other higher-level protocols. During execution, when a context is required for the activity associated with the current execution environment, the Context Service calls each registered ALS and obtains additional content for the basic context from it; from this it eventually assembles the entire context document that can be propagated.
The relationship between ALS and context service, application services, and applications is shown in Figure 1.
WS-Context does not mandate how contexts are actually created, but the canonical route is via the Activity Lifecycle services, which "plug-in" to the Context Service. In this respect, the exact structure and semantics of an activity are defined by the combination of ALSs that have been associated with the activity. For example, a Context Service may have a transaction ALS and security ALS registered with it, so that when an activity is started, any context that is created will contain any necessary transaction and security information.
WS-Coordination Framework (WS-CF)
While WS-Coordination Framework is ostensibly similar to WS-Coordination, the main differentiator is that WS-CF defines more of the coordinator's architecture than WS-Coordination (which leaves most things up to the services that use it). For example, in WS-CF you can actually inquire as to the status of a coordinator without having to know the details of the protocol (and its implementation). In many ways, WS-CF can be considered a superset of the WS-Coordination.
Figure 2 illustrates how individual Web services as well as composite applications can register as participants with a coordinator, which takes over responsibility for context management and notifying participants of the outcome of a series of related Web services executions. As the figure shows, a coordinator can register itself with another coordinator and become a participant, thereby improving interoperability.
WS-Transaction Management (WS-TXM)
WS-TXM actually embodies three separate extended transaction protocols. Like WS-Transaction and BTP, WS-TXM provides models that are designed to accommodate multiple use cases, from tightlycoupled intranet-based transactions (TXACID), to Internet-scale, long-lived transactions (TX-LRA), to business process-oriented transactions (TX-BP).
Long Running Activities (LRA)
There is a caveat to this model though. Application services may not be compensatable (e.g., an application-level service that prints and mails checks), or the ability to compensate may be transient. The LRA model allows applications to combine services that can be compensated with those that cannot be compensated. Obviously, by mixing the two service types the user may end up with a business activity that will ultimately not be undone by the LRA model, but which may require outside (application-specific) compensation.
The LRA model defines a protocol actor called a compensator that operates on behalf of a service to undo the work it performs within the scope of an LRA. How compensation is carried out will obviously be dependent upon the service; compensation work may be carried out by other LRAs which themselves have compensators.
When a service performs work that may later have to be compensated within the scope of an LRA, it enlists a compensator participant with the LRA coordinator. The coordinator will send the compensator one of the following messages when the activity terminates:
LRAs may be used both sequentially and concurrently, where the termination of an LRA signals the start of some other unit of work within an application. However, LRAs are units of compensatable work and an application may have as many units of work operating simultaneously as it needs to accomplish its tasks. Furthermore, the outcome of work within LRAs may determine how other LRAs are terminated.
An application can be structured so that LRAs are used to assemble units of compensatable work and then held in the active state while the application performs other work in the scope of different (concurrent or sequential) LRAs. Only when the right subset of work (LRAs) is arrived at by the application will that subset be confirmed; all other LRAs will be told to cancel (complete in a failure state).
Business Process (BP)
In the business process transaction model, all parties involved in a business process reside within business domains, which may themselves use business processes to perform work. Business process transactions are responsible for managing interactions between these domains. A business process is split into business tasks and each task executes within a specific business domain. A business domain may itself be subdivided into other business domains recursively.
Each domain may represent a different transaction model if such a federation of models is more appropriate to the activity. Each business task (which may be modelled as a scope) may provide implementation- specific countereffects in the event the enclosing scope must cancel. Furthermore, the controlling application may periodically request that all business domains checkpoint their state so that they can either be consistently rolled back to that checkpoint by the application or restarted from the checkpoint in the event of a failure.
Figure 4 shows an online travel agent interacting with its suppliers, each of which resides in its own business domain. The work necessary to obtain each component is modelled as a separate task. In this example, the Flight Reservation task is actually composed of two subtasks - one gets the flight and the other gets the necessary travel insurance.
In this example, the user may interact synchronously with the travel agent to build up the required details of the holiday. Or, the user may submit an order (possibly with a list of alternate requirements, such as destinations, dates, etc.) to the agent, who will call back when it has been filled. Likewise, the travel agent then submits orders to each supplier, requiring them to call back when each component is available (or is known to be unavailable).
Business domains are instructed to perform work within the scope of a global business process. The business process has an overall manager that may be informed by individual tasks when they have completed their work or it may periodically communicate with each task to determine its current status. In addition, each task may make checkpoints of its progress so if a failure occurs, it may be restarted from that point rather than having to start from the beginning. A business process can either terminate in a confirmed (successful) manner, in which case all of the work requested will have been performed, or it will terminate in a cancelled (unsuccessful) manner, in which case all of the work will be undone.
If it cannot be undone, then this fact must be logged.
Comparison Between OASIS BTP and WS-Coordination/Transaction
OASIS BTP was the first transaction protocol to gain real traction for Web services. It consists of a single API that supports two distinct transaction models, known as atom and cohesion. The atom model is a straightforward two-phase protocol where all participants in a transaction see the same outcome, although BTP does not impose any semantics on what action a particular participant takes on receipt of an outcome message (an atom may or may not be ACID). The cohesion model is more complex, and allows the set of participants to change throughout the duration of the transaction, up until the point when the confirmation protocol executes. However, unlike the atom model, BTP cohesions may deliver different outcome messages to individual participants, based on the combination of responses from participants and some business logic.
Similarly, WS-Transaction has two transaction models: atomic transactions require ACID semantics and mandate that resources are locked for the transaction's duration. Business activities, on the other hand, are designed for use in long-running transactions. They ensure that any updates to state in a system are made immediately, significantly reducing the period during which locks must be held. WS-Transaction has no notion of a two-phase commit for a business activity because commits are made immediately on receipt of the associated messages. If a failure occurs, a business activity runs compensating actions to restore data to a consistent form.
Underpinning WS-Transaction is WS-Coordination, which provides a generic mechanism for context creation and coordination and is extended through protocol plug-ins that provide domain-specific coordination facilities.
Figure 5 highlights the two key differences between the specifications. The most striking feature is that each offers different transaction models at the uppermost layers, but it is important to note that the WS-Coordination layer in the WSTransaction/ WS-Coordination stack is also available for applications to build on. In the WS-CAF stack, the WS-Context layer is also exposed for use.
Reader Feedback: Page 1 of 1
SOA World Latest 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