Welcome!

Microservices Expo Authors: Elizabeth White, Karthick Viswanathan, Cameron Van Orman, Jason Bloomberg, Pat Romanski

Related Topics: Microservices Expo

Microservices Expo: Article

Introducing WS-Transaction Part II

Introducing WS-Transaction Part II

In July 2002, BEA, IBM, and Microsoft released a trio of specifications designed to support business transactions over Web services. BPEL4WS, WS-Transaction, and WS-Coordination together form the bedrock for reliably choreographing Web services-based applications.

In our previous articles (WSJ, Vol. 3, issues 5 and 6), we introduced WS-Coordination, a generic coordination framework for Web services, and showed how the WS-Coordination protocol can be augmented to provide atomic transactionality for Web services via the WS-Transaction Atomic Transaction model.

This article looks at support for extended transactions across Web services. We also show how these can be used to provide the basis for higher-level business process management and workflow technology.

Business Activities
Most business-to-business applications require transactional support in order to guarantee consistent outcome and correct execution. These applications often involve long-running computations, loosely coupled systems, and components that don't share data, location, or administration. It's difficult to incorporate atomic transactions within such architectures. For example, an online bookshop may reserve books for an individual for a specific period of time, but if the individual doesn't purchase the books within that period they will be "put back onto the shelf" for others to buy. Furthermore, because it is impossible for anyone to have an infinite supply of stock, some online shops may appear to reserve items, but in fact may allow others to preempt that reservation (i.e., the same book may be "reserved" for multiple users concurrently); a user may subsequently find that the item is no longer available, or has to be reordered for them.

A business activity (BA) is designed specifically for these long-duration interactions, where exclusively locking resources is impossible or impractical. In this model, services are requested to do work, and where those services have the ability to undo any work, they inform the BA so that if the BA later decides to cancel the work (i.e., if the business activity suffers a failure), it can instruct the service to execute its undo behavior. The key point for business activities is that how services do their work and provide compensation mechanisms is not the domain of the WS-Transaction specification, but an implementation decision for the service provider.

The BA defines a protocol for Web services-based applications to enable existing business processing and workflow systems to wrap their proprietary mechanisms and interoperate across implementations and business boundaries.

A BA may be partitioned into scopes - business tasks or units of work using a collection of Web services. Scopes can be nested to arbitrary degrees, forming parent and child relationships, where a parent scope can select which child tasks to include in the overall outcome protocol for a specific business activity, so nonatomic outcomes are possible. In a manner similar to traditional nested transactions, if a child task experiences an error it can be caught by the parent, who may be able to compensate and continue processing.

When a child task completes it can either leave the business activity or signal to the parent that the work it has done can be compensated later. In the latter case, the compensation task may be called by the parent should it ultimately need to undo the work performed by the child.

Unlike the atomic transaction protocol model, where participants inform the coordinator of their state only when asked, a task within a BA can specify its outcome to the parent directly without waiting for a request. When tasks fail, the notification can be used by the business activity exception handler to modify the goals and drive processing forward without waiting meekly until the end of the transaction to admit to having failed - a well-designed BA should be proactive if it is to be performant.

Underpinning all of this are three fundamental assumptions:

  • All state transitions are reliably recorded, including application state and coordination metadata (the record of sent and received messages).
  • All request messages are acknowledged, so problems are detected as early as possible. This eliminates unnecessary tasks and can detect a problem earlier, when rectifying it is simpler and less expensive.
  • As with atomic transactions, a response is defined as a separate operation and not as the output of the request. Message input-output implementations will typically have timeouts that are too short for some business activity responses. If the response is not received after a timeout, it is sent again. This is repeated until a response is received. The request receiver discards all but one identical request received.

    The business activity model has multiple protocols: BusinessAgreement and BusinessAgreementWithComplete. However, unlike the AT protocol, which is driven from the coordinator down to participants, this protocol is driven from the participants upwards.

    Under the BusinessAgreement protocol, a child activity is initially created in the Active state; if it finishes the work it was created to do and no more participation is required within the scope of the BA (such as when the activity operates on immutable data), the child can unilaterally send an exited message to the parent. However, if the child task finishes and wishes to continue in the BA, then it must be able to compensate for the work it has performed. In this case it sends a completed message to the parent and waits to receive the final outcome of the BA from the parent. This outcome will be either a close message - the BA has completed successfully - or a compensate message - the parent activity requires that the child task reverse its work.

    The BusinessAgreementWithComplete protocol is identical to the BusinessAgreement protocol with the exception that the child cannot autonomously decide to end its participation in the business activity, even if it can be compensated. Rather, the child task relies upon the parent to inform it when the child has received all requests for it to perform work. The parent does this by sending the complete message to the child, which then acts as it does in the BusinessAgreement protocol.

    The crux of the BA model, compared to the AT model, is that it allows the participation of services that cannot or will not lock resources for extended periods.

    While the full ACID semantics are not maintained by a BA, consistency can be maintained through compensation, although writing correct compensating actions (and thus overall system consistency) is delegated to the developers of the services controlled by the BA. Such compensations may use backward error recovery, but typically employ forward recovery.

    Coordinating Business Activities on the Web
    However, the real beauty of the Web services model is that it is highly modular. Capitalizing on that modularity, consider the case shown in Figure 1, where a shopping portal uses several suppliers to deliver a richer shopping experience to the customer.

     

    In this case, a BA is used since there is no close trust relationship between any of the suppliers (indeed they are probably competitors), and purchases are committed immediately as per the BA model. In the non-failure case, things are straightforward and each child BA reports back that it has completed to the coordinator via a completed message.

    The failure case, however, is a little more interesting (see Figure 2). Let's assume that Supplier 2 could not source the tie that the customer wanted and its corresponding BA fails. It reports the failure back to the coordinator through a faulted message. On receiving this message, the logic driving the BA, which we assume to be a workflow script residing in the portal service, is invoked to deal with the fault. In this case, the logic uses forward error recovery to try to obtain the item from an alternative supplier.

     

    If the forward error recovery works, and the alternate supplier's Web service confirms that it is able to source the desired item, then the BA proceeds normally, executing subsequent child BAs until completion. If, however, the BA cannot make forward progress and it thus has no option but to go backwards and compensate previous successfully completed activities. Note that failed activities are not compensated because their state is, by definition, unknown.

    Once the compensation has taken place successfully (remember that an added complexity is that compensations can themselves fail), the system should be in a state that is semantically equivalent to the state it was in before the purchase operations were carried out. The shopping portal service knows the status of the transaction from the coordinator, and can then report back to the customer application that the order didn't complete.

    Business Activities and BPEL4WS
    During the execution of a business process, like our shopping portal example, data in the various systems that the process encompasses changes. Normally such data is held in mission-critical enterprise databases and queues, which have ACID transactional properties to ensure data integrity. This can lead to a situation whereby a number of valid commits to databases could have been made during the course of a process, but where the overall process might fail, leaving work partially completed. In such situations the reversal of partial work cannot rely on backward error recovery mechanisms - rollback - supported by the databases since the updates to the database will have been long since committed. Instead, we must compensate at the application level by performing the logical reverse of each activity that was executed as part of our process, from the most recently executed scope back to the earliest executed scope. This model is known as a saga, and is the default compensation model supported by BPEL4WS.

    The BPEL4WS specification suggests WS-Transaction Business Activity as the protocol of choice for managing transactions that support the interactions of process instances running within different enterprise systems. A business activity is used both as the means of grouping distributed activities into a single logical unit of work and the dissemination of the outcome of that unit of work - whether all scopes completed successfully or need to be compensated.

    If each of the Web services in our shopping portal example were implemented as BPEL4WS workflow scripts, the messages from the BA protocol messages from the coordinator could be consumed by those workflow scripts and used to instigate any compensating activities for those activities. The execution of compensating activities caused by the coordinator sending compensate messages to the participants returns the process as a whole to the same state logically as it was before the process executed.

    Relationship to OASIS BTP
    The OASIS Business Transactions Protocol (BTP) was developed by a consortium of companies, including Hewlett-Packard, Oracle, and BEA, to tackle a similar problem to WS-Transaction: business-to-business transactions in loosely coupled domains. BTP was designed with loose coupling of services in mind and integration with existing enterprise transaction systems was not a high priority. Web services were also not the only deployment environment considered by the BTP developers so the specification only defines an XML protocol message set, and leaves the binding of this message set to specific deployment domains.

    BTP defines two transaction models: atoms, which guarantee atomicity of decision among participants; and cohesions, which allow relaxed atomicity such that subsets of participants can see different outcomes in a controlled manner. Both models use a two-phase completion protocol, which deliberately does not require ACID semantics: although it is similar to the 2PC protocol used by WS-Transaction Atomic Transactions, it is used purely to attain consensus and no semantics can be inferred from higher-level services that use atoms. An implementer of a BTP participant is free to use compensation techniques in the second-phase operations to guarantee atomicity if that model best suits the business.

    Both atoms and cohesions also use the open-top coordination protocol, whereby both phases of the two-phase protocol must be explicitly executed by users. Because no time limit is implied between the two phases of the completion protocol, this explicit separation of the phases is intended to allow businesses to better model their business processes.

    Although at least in theory WS-Transaction and BTP are intended to address the same problem domain, there are significant differences between them. BTP allows business-level negotiation to occur during many points in the protocol in its Qualifier mechanism; WS-Transaction does not have such a capability.

    Summary
    Over the course of these articles, we've seen both the atomic AT protocol and the non-ACID BA designed to support long-running transactions. While both the AT and BA models will be available to Web services developers directly through toolkits, it is the BA model that is supported by the BPEL4WS standard to provide distributed transaction support for business processes.

  • More Stories By Jim Webber

    Dr. Jim Webber is a senior researcher from the University of Newcastle
    upon Tyne, currently working in the convergence of Web Services and Grid
    technologies at the University of Sydney, Australia. Jim was previously
    Web Services architect with Arjuna Technologies where he worked on Web
    Services transactioning technology, including being one of the original
    authors of the WS-CAF specification. Prior to Arjuna, Jim was the lead
    developer with Hewlett-Packard on the industry's first Web Services
    Transaction solution. Co-author of "Developing Enterprise Web Services -
    An Architect's Guide," Jim is an active speaker and author in the Web
    Services space. Jim's home on the web is http://jim.webber.name

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    @MicroservicesExpo Stories
    Is advanced scheduling in Kubernetes achievable? Yes, however, how do you properly accommodate every real-life scenario that a Kubernetes user might encounter? How do you leverage advanced scheduling techniques to shape and describe each scenario in easy-to-use rules and configurations? In his session at @DevOpsSummit at 21st Cloud Expo, Oleg Chunikhin, CTO at Kublr, will answer these questions and demonstrate techniques for implementing advanced scheduling. For example, using spot instances ...
    These days, APIs have become an integral part of the digital transformation journey for all enterprises. Every digital innovation story is connected to APIs . But have you ever pondered over to know what are the source of these APIs? Let me explain - APIs sources can be varied, internal or external, solving different purposes, but mostly categorized into the following two categories. Data lakes is a term used to represent disconnected but relevant data that are used by various business units wit...
    DevSecOps – a trend around transformation in process, people and technology – is about breaking down silos and waste along the software development lifecycle and using agile methodologies, automation and insights to help get apps to market faster. This leads to higher quality apps, greater trust in organizations, less organizational friction, and ultimately a five-star customer experience. These apps are the new competitive currency in this digital economy and they’re powered by data. Without ...
    Today most companies are adopting or evaluating container technology - Docker in particular - to speed up application deployment, drive down cost, ease management and make application delivery more flexible overall. As with most new architectures, this dream takes significant work to become a reality. Even when you do get your application componentized enough and packaged properly, there are still challenges for DevOps teams to making the shift to continuous delivery and achieving that reducti...
    With the modern notion of digital transformation, enterprises are chipping away at the fundamental organizational and operational structures that have been with us since the nineteenth century or earlier. One remarkable casualty: the business process. Business processes have become so ingrained in how we envision large organizations operating and the roles people play within them that relegating them to the scrap heap is almost unimaginable, and unquestionably transformative. In the Digital ...
    With the rise of DevOps, containers are at the brink of becoming a pervasive technology in Enterprise IT to accelerate application delivery for the business. When it comes to adopting containers in the enterprise, security is the highest adoption barrier. Is your organization ready to address the security risks with containers for your DevOps environment? In his session at @DevOpsSummit at 21st Cloud Expo, Chris Van Tuin, Chief Technologist, NA West at Red Hat, will discuss: The top security r...
    The nature of the technology business is forward-thinking. It focuses on the future and what’s coming next. Innovations and creativity in our world of software development strive to improve the status quo and increase customer satisfaction through speed and increased connectivity. Yet, while it's exciting to see enterprises embrace new ways of thinking and advance their processes with cutting edge technology, it rarely happens rapidly or even simultaneously across all industries.
    Most of the time there is a lot of work involved to move to the cloud, and most of that isn't really related to AWS or Azure or Google Cloud. Before we talk about public cloud vendors and DevOps tools, there are usually several technical and non-technical challenges that are connected to it and that every company needs to solve to move to the cloud. In his session at 21st Cloud Expo, Stefano Bellasio, CEO and founder of Cloud Academy Inc., will discuss what the tools, disciplines, and cultural...
    Enterprises are moving to the cloud faster than most of us in security expected. CIOs are going from 0 to 100 in cloud adoption and leaving security teams in the dust. Once cloud is part of an enterprise stack, it’s unclear who has responsibility for the protection of applications, services, and data. When cloud breaches occur, whether active compromise or a publicly accessible database, the blame must fall on both service providers and users. In his session at 21st Cloud Expo, Ben Johnson, C...
    21st International Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Me...
    ‘Trend’ is a pretty common business term, but its definition tends to vary by industry. In performance monitoring, trend, or trend shift, is a key metric that is used to indicate change. Change is inevitable. Today’s websites must frequently update and change to keep up with competition and attract new users, but such changes can have a negative impact on the user experience if not managed properly. The dynamic nature of the Internet makes it necessary to constantly monitor different metrics. O...
    Agile has finally jumped the technology shark, expanding outside the software world. Enterprises are now increasingly adopting Agile practices across their organizations in order to successfully navigate the disruptive waters that threaten to drown them. In our quest for establishing change as a core competency in our organizations, this business-centric notion of Agile is an essential component of Agile Digital Transformation. In the years since the publication of the Agile Manifesto, the conn...
    Many organizations are now looking to DevOps maturity models to gauge their DevOps adoption and compare their maturity to their peers. However, as enterprise organizations rush to adopt DevOps, moving past experimentation to embrace it at scale, they are in danger of falling into the trap that they have fallen into time and time again. Unfortunately, we've seen this movie before, and we know how it ends: badly.
    There is a huge demand for responsive, real-time mobile and web experiences, but current architectural patterns do not easily accommodate applications that respond to events in real time. Common solutions using message queues or HTTP long-polling quickly lead to resiliency, scalability and development velocity challenges. In his session at 21st Cloud Expo, Ryland Degnan, a Senior Software Engineer on the Netflix Edge Platform team, will discuss how by leveraging a reactive stream-based protocol,...
    Many organizations adopt DevOps to reduce cycle times and deliver software faster; some take on DevOps to drive higher quality and better end-user experience; others look to DevOps for a clearer line-of-sight to customers to drive better business impacts. In truth, these three foundations go together. In this power panel at @DevOpsSummit 21st Cloud Expo, moderated by DevOps Conference Co-Chair Andi Mann, industry experts will discuss how leading organizations build application success from all...
    The last two years has seen discussions about cloud computing evolve from the public / private / hybrid split to the reality that most enterprises will be creating a complex, multi-cloud strategy. Companies are wary of committing all of their resources to a single cloud, and instead are choosing to spread the risk – and the benefits – of cloud computing across multiple providers and internal infrastructures, as they follow their business needs. Will this approach be successful? How large is the ...
    You know you need the cloud, but you’re hesitant to simply dump everything at Amazon since you know that not all workloads are suitable for cloud. You know that you want the kind of ease of use and scalability that you get with public cloud, but your applications are architected in a way that makes the public cloud a non-starter. You’re looking at private cloud solutions based on hyperconverged infrastructure, but you’re concerned with the limits inherent in those technologies.
    "NetApp's vision is how we help organizations manage data - delivering the right data in the right place, in the right time, to the people who need it, and doing it agnostic to what the platform is," explained Josh Atwell, Developer Advocate for NetApp, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
    The “Digital Era” is forcing us to engage with new methods to build, operate and maintain applications. This transformation also implies an evolution to more and more intelligent applications to better engage with the customers, while creating significant market differentiators. In both cases, the cloud has become a key enabler to embrace this digital revolution. So, moving to the cloud is no longer the question; the new questions are HOW and WHEN. To make this equation even more complex, most ...
    One of the biggest challenges with adopting a DevOps mentality is: new applications are easily adapted to cloud-native, microservice-based, or containerized architectures - they can be built for them - but old applications need complex refactoring. On the other hand, these new technologies can require relearning or adapting new, oftentimes more complex, methodologies and tools to be ready for production. In his general session at @DevOpsSummit at 20th Cloud Expo, Chris Brown, Solutions Marketi...