Return to Home Page

The public review of the manuscript for "SOA Design Patterns" has concluded !
Thank you to all that participated. 234 reviews were received and over 30 new patterns have been contributed,
increasing the size of this book by over 50%. The second draft of the manuscript is currently in development.

About the Public Review
    History
    Podcasts (audio)
    Notification
    Submit Feedback
    Contribute a Proven Pattern
    Contribute a Candidate Pattern
    Acknowledgements
    Press Release

Introduction to SOA Types & Design Patterns
    The Architecture of
Service-Orientation
    Understanding SOA
Design Patterns

SOA Design Patterns
    Basic Service Inventory Design Pattern Language
    Architectural Design Patterns
    Basic Service Design
Pattern Language
    Service Design Patterns
    Common Compound
Design Patterns

Additional Resources
    View Entire TOC
    Symbol Legend
    Master Pattern List
(by category)
    Candidate Design Patterns
    Design Patterns Publications
    Download SOA Principles Poster (PDF)

About the Book



SOA Design Patterns
by Thomas Erl

For more information visit: www.soapatterns.com

Related Publications


Read the article "Introducing SOA Design Patterns" from the
June 2008 SOA World Magazine (High-Res PDF).

PLEASE NOTE

The content on this page is from the first draft of the manuscript for the upcoming book "SOA Design Patterns" by Thomas Erl. This version of the manuscript was authored in September, 2007. Since then, the manuscript has undergone significant content and structural changes as a result of an industry-wide review in which hundreds of SOA practitioners participated in addition to SOA vendors and experts from the design patterns community.

You are welcome to use the information on this page for research purposes, but you should assume that most of it will change in the final release of the "SOA Design Patterns" book.

Note also, that as a result of an industry-wide call for participation from December 2007 to February 2008, over 30 new design patterns have been contributed to this book. As they become finalized and are incorporated by the author, concise descriptions will be published on this site, and full descriptions with examples will be made available in the final, printed book.

Due to the volume of new content and changes, the release of the "SOA Design Patterns" book has been postponed to October, 2008. To learn more about the book, visit www.soapatterns.com. To be notified of updates to this site, use the notification form.

Chapter 6: Architectural Design Patterns

Home > Chapter 6 Overview > Asynchronous Queuing
Asynchronous Queuing

Asynchronous Queuing

How can a service and its consumers accommodate isolated failures and avoid unnecessarily locking resources?

Problem

When a service capability requires that consumers interact with it synchronously, it can inhibit performance and compromise reliability.

Solution

A service can exchange messages with its consumers via an intermediary buffer (such as a queue), allowing service and consumers to process messages independently by remaining temporally decoupled.

Application

Queuing technology needs to be incorporated into the surrounding architecture and back-up stores may also be required.

Impacts

There may be no acknowledgement of successful message delivery and atomic transactions may not be possible.

Principles

Standardized Service Contracts, Service Loose Coupling, Service Statelessness

Architecture

Inventory, Composition

Table 6.2 – Profile summary for the Asynchronous Queuing pattern.

Problem

Synchronous communication requires an immediate response to every request and therefore forces two-way data exchange for every service interaction. When services are required to carry out synchronous communication, both service and service consumer must be available and ready to complete the data exchange. This can introduce reliability issues when either the service cannot guarantee its availability to receive the request message or the service consumer cannot guarantee its availability to receive the response to its request.

Because of its sequential nature, synchronous message exchanges can further impose processing overhead, as the service consumer needs to wait until it receives a response from its original request before proceeding to its next action. As shown in Figure 6.x, prolonged responses can introduce latency by temporally locking both consumer and service.

Figure 6.8 –Service A (the service consumer) issues a request message to Service B and because it is part of a synchronous data exchange, Service A is required to wait until Service B processes the request message and then transmits a response. During this waiting period, both service and consumer must be available and continue to use up memory.

Another problem forced synchronous communication can cause is an overload of services required to facilitate a great deal of concurrent access. Because services are expected to process requests as soon as they are received, usage thresholds can be more easily reached, thereby exposing the service to risk of multi-consumer latency or overall failure.

Solution

A queue is introduced as an intermediary buffer that receives request messages and then forwards them on behalf of the service consumers. If the target service is unavailable, the queue acts as a persistent buffer and retains the message. It then periodically attempts retransmission.

Similarly, if there is a response, it can be issued through the same queue that will forward it back to the service consumer when the consumer is available. While either service or consumer is processing message contents, the other can deactivate itself (or move on to other processing) in order to minimize memory consumption.

Figure 6.9 – Service A (the service consumer) sends a message to Service B, which is intercepted and stored by an intermediary queue (1). The queue the forwards the message to Service B (2) and while Service B is processing the message, Service A remains released from memory (3).

Figure 6.10 – After completing its processing, Service B issues a response message back to Service A which is also received and stored by the intermediary queue (4). Service A receives the response (5) and completes processing of the response, all the while Service B is deactivated (6).

Application

In modern ESB platforms, the use of a queue can be completely transparent, meaning that neither consumer nor service may know that it was involved in a data exchange. The queuing framework is supported by intelligent service agents that detect when a queue is required and intercept message transmissions accordingly.

The queue can be configured to process messages in different ways, and is typically set up to poll an unavailable target recipient periodically until it becomes available or until the message transmission is considered to have failed. Queues can further be used to leverage asynchronous message exchange by incorporating topics and message broadcasts to multiple consumers, as per a typical publish-and-subscribe exchange pattern.

Many vendor queues are equipped with a back-up store so that messages in transit are not lost should a system failure occur. Especially when supporting more complex compositions, the Asynchronous Queuing design pattern is commonly applied in conjunction with the Reliable Messaging pattern.

Impacts

The use of intermediary queues allows for creative asynchronous message exchange patterns that can optimize service interaction by eliminating the need for a required response to each request. However, asynchronous message exchanges can also lead to more complex service activities that are difficult to design. It may be challenging to anticipate all of the possible runtime scenarios at design-time, and therefore extra exception handling logic may be necessary.

An asynchronous data exchange that involves a queue can also be more difficult to control and monitor. It may not be possible to wrap asynchronous activities within an atomic transaction because of the time-response constraints usually associated with transactions and their requirements to hold resources in suspension until either commit or rollback instructions are issued.

Despite these issues, an advantage to synchronous messaging is that because a response is always required, it acts as an immediate acknowledgement that the initial request message was successfully delivered and processed. With asynchronous message exchange patterns (such as Òone-wayÓ and ÒsolicitÓ) no response is expected and the message issuer therefore is not notified of successful or failed deliveries. However, most queuing systems allow the monitoring and administration of in-flight message transmissions. Messages in the queue can be furthermore examined and managed during transit which, in larger systems, can greatly simplify administrative control and the isolation of communication faults.

Relationships

Asynchronous Queuing is a design pattern dedicated to accommodating message exchanges and therefore is naturally related to the Service Messaging and Message-Level Security patterns.

Event-driven agents and intercepts form a fundamental part of the queuing framework, which explains the relevance of the Service Agent pattern. Furthermore, Messaging Metadata can play a role in how messages are processed, stored, or routed via these agents (Figure 6.x).

Figure 6.11 – The Asynchronous Queuing patternÕs message-centric focus naturally leads to relationships with other messaging patterns.

Enterprise service bus platforms are fundamentally about decreasing the coupling between different parts of a service-oriented solution, which is why this pattern is a core part of the Enterprise Service Bus compound pattern (Figure 6.x).

Figure 6.12 – Asynchronous Queuing is a design pattern that can be applied independently, but also represents one of the core patterns that comprise the Enterprise Service Bus compound pattern.

As explained in Chapter 9, an optional design pattern associated with the ESB is Reliable Messaging, which is a pattern commonly applied in conjunction with Asynchronous Queuing. Together, these two patterns provide key QoS extensions that make the use of ESB products attractive, especially in support of complex service compositions.

Case Study Example

Case study content is not available on this Web site.

Prev | Next
The Prentice Hall Service-Oriented Computing Series from Thomas Erl
Home    SOA Books    SOA Magazine    What is SOA?    SOA Principles    SOA Methodology    SOA Glossary Copyright © 2007-2008
SOA Systems Inc.