Welcome!

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

Related Topics: Microservices Expo

Microservices Expo: Article

Web Services Infrastructure

Web Services Infrastructure

It's a fact: Web services have started to mature. Those emergent standards that once held so much promise are now actually starting to deliver useful implementations. With the basic Web services plumbing mastered, we're starting to see more advanced infrastructure, which enables these second-generation Web services to focus on complex interactions over the Internet. This article, the first of a two-part series, covers one such aspect of the second-generation infrastructure for Web services: transactions.

Overview
The OASIS Business Transactions Protocol, or BTP, has become the prominent standard for Web services transactions. BTP is the product of just over a year's work by vendors such as HP, BEA, and Oracle, and has resulted in the development of a transaction model particularly suited to loosely coupled systems like Web services.

In this article, we're going to look at how BTP fits into the whole Web services architecture, and how we can use one of the vendor toolkits (we'll use HP's toolkit, but the underlying principles apply to other vendors' software) to build and consume transaction-aware Web services. But before we do, let's review the architecture in the context of a simple transactional scenario.

The diagram shown in Figure 1 is similar to a typical high-level Web services architecture. The only differences here are that one service, the transaction manager, has been singled out as being distinct from the other Web services (which we assume are responsible for some aspects of a business process), and the fact that we've chosen to identify two distinct categories of messages: control messages (which are used to control transactions) and application messages (which propagate application data around the system).

 

Of course, if it really were as simple as deploying a transaction manager service into the architecture, then this article wouldn't be necessary. Unfortunately it's not that simple; or at least not quite that simple, as we shall see. To illustrate, it's convenient to use Figure 1 as a point of reference as we work through the architecture, filling in the details. We'll work from left to right, from the client through to the Web services, and cover everything in between.

Consuming Transactional Web Services
Though Web services is a hot technology, we shouldn't lose sight of the fact that it exists to support business processes. With that in mind, the right place to start our investigation is most definitely at the client end of a system - where the results of Web services interactions are brought together and where the value of a business process is ultimately focused. To place this in the proper context, it's useful to see an exploded view of the client-side infrastructure, shown in Figure 2.

 

In a nontransactional Web services- based application, the client process can be something as simple as a collection of calls (via proxies) to services that are involved in the activity. In a transactional Web services-based application, the same is (surprisingly enough) true, with the caveat that the developer must demarcate any transactions that support business logic, as well as deal with application-specific calls. In this case the transaction demarcation is supported by the client transaction API (the Client Tx API in Figure 2), whereas the business methods supported by service proxies appear to logically remain free of any transactional infrastructure from the point of view of the client application developer. In fact, under the covers there is a mechanism that performs context associations with local threads of control within the client and messages passed between the client and (transactional) Web services. In Figure 2, this is the purpose of the Tx Context Interceptor.

Client API
The client API provides the developer with the necessary tools with which to structure and control transactions within the application. The commands available to a developer in a transactional Web services environment are quite familiar to those of us that have used other transaction APIs in the past, with the caveat that BTP supports full control over both phases of the commit process and thus has a larger command set than we might otherwise envision. The UserTransaction API supports the common verbs (and by implication the methods that enact those verbs) for transaction demarcation:

  • Begin: Creates a new top-level transaction (or subtransaction) for either atomic or cohesive transactions
  • Prepare: Instructs an atomic transaction to prepare its associated participating services when the transaction is to terminate
  • Prepare Inferiors: Instructs a cohesive transaction to prepare one or more of its participating services at transaction termination time
  • Confirm: Instructs an atomic transaction to confirm all of its participating services, and confirms all participant services that voted to confirm in the case of a cohesive transaction
  • Cancel: Instructs all participating services in an atomic transaction, or those services specified in the parameter to the method call in a cohesive transaction, to cancel In addition to these demarcation verbs, a number of other commands can be used to inquire about a transaction:
  • Status: Asks the transaction manager to return the state (e.g., committed, preparing) of the current transaction
  • Transaction type: Exposes the type of the current transaction (i.e., atom or cohesion)
  • Transaction name: Exposes the name of the current transaction in string form

    Two verbs allow advanced manual transaction management:

  • Suspend: Disassociates the current thread from the current transaction
  • Resume: (Re)associates the current thread with the current transaction

    Those who have previously worked with transactions will immediately find themselves at home with this API, since it is in the same spirit as other transaction APIs like JTA. Let's take a look at an example.

    In the code shown in Listing 1, we see an atom being used to ensure a consistent outcome across calls to the Web services shown in Figure 1. Initially we obtain a reference to an instance of UserTransaction from a (previously initialized) UserTransactionFactory, which we then use to delimit the scope of the single transaction in our application. Our atomic transaction is started by calling the begin(...) method on the user transaction API and specifying the type of transaction as an atom. From now on the business logic is straightforward and contains no further transaction control primitives; we simply go ahead and make the bookings we want for our night out through the book(...) methods of the service proxies we created.

    Once the business logic has completed, we can terminate the transaction by calling prepare(...) and confirm(...) which, in the absence of failures, should confirm to all parties that they should henceforth honor all our booking requests. If there are failures, then all parties are informed and should take the necessary steps to undo any work undertaken on our behalf, while the client application will receive an exception that details what exactly has gone wrong.

    The great thing about this example is that it shows just how simple and relatively noninvasive it can be to wrap work with Web services within a transaction. In fact, the business logic aspects of the code would be the same irrespective of whether or not transactions are used.

    Under the Covers:
    BTP's Two-Pipe Model

    To support transactional Web services-based applications, BTP utilizes two distinct types of messages that the client application exchanges with business Web services. The first of these messages is exchanged exclusively within the transaction infrastructure. The other type consists of messages that the client exchanges with business Web services onto which BTP messages might be piggybacked.

    The messages that the application exchanges with the transaction infrastructure are encapsulated by the primitives supported by the client API. For example, a begin(...) method being executed by the client causes a corresponding BTP begin message to be sent to a transaction manager via the SOAP server, and for response messages from the transaction manager to be processed in the reverse order. This is shown in Figure 3, and a sample BTP message (begin) is shown in Listing 2. The only slightly unusual aspect to this example is that the response to begin messages (and only begin messages) is cached for later use so local threads of execution can be associated with the BTP transaction under which its work is being carried out.

     

    When transporting application messages, the situation is a little different. Unlike BTP messages in which the message content travels in the body of the SOAP envelope, when application messages are sent, application-specific content travels in the body, while any BTP messages are relegated to the header part of the envelope. We can see this in Listing 3, in which the SOAP body carries the application payload, while the header is used to carry the BTP context.

    This scheme works well since most SOAP stacks are well equipped to perform efficient header processing, and placing the BTP content, including the transaction context, in the header means that SOAP actors can pick out the parts of the header space that are of interest without having to parse the whole application payload. From a development point of view, most SOAP servers support pluggable header processors, which means that building BTP context processing into your infrastructure should be straightforward. To demonstrate that point, let's take a look at the general client-side architecture (which is based on Apache Axis in the toolkit we've used), as per the examples in Figure 3 and Listing 2.

    Figure 4 shows the outward path of a call to a Web service, starting from the left with the local method call to a service proxy. The call then follows the logical path of being converted to the appropriate SOAP body, which contains the application payload, before it progresses to the outgoing context handler. The context handler takes advantage of the fact that the information supplied in response to the BTP begin message was recorded, and is able to produce a BTP context from that data, which it duly inserts into the SOAP envelope's header. If there is no contextual data stored for the current thread (i.e., it isn't part of a transaction or the transaction has been deliberately suspended), then the context insertion is simply bypassed.

     

    For return messages, the strategy is simply the reverse, as shown in Figure 5, in which the flow is from right to left. Responses are quickly scanned to see if they contain any BTP context entries in their headers. If context data is present, it is stripped out of the message and may be used to resume the transaction locally by associating the current thread while the rest of the message passes through to the service proxies. Once at the service proxies, the local method call returns control to the client, which is unaware of all of the additional processing that has occurred on its behalf.

     

    Having reached the point where we can send application messages with BTP contexts, as well as BTP messages themselves, we're able to follow the messages as they travel across the wire. Following the cables inevitably leads us to business Web services.

    Summary
    The first article in this series on implementing transactional Web services- based applications has shown how client applications can be constructed using off-the-shelf BTP toolkits. We've seen how much of the hard work involved in managing transactions has been delegated to the toolkit and the underlying SOAP infrastructure, leaving to the developer the real value-add work of getting the application logic and transaction structure right. However, this is only half the story. In the next article, we'll investigate what happens at the Web service end, and show how true enterprise-class Web services applications can be made transactional from end to end.

  • 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...