With its roots in the messaging-oriented middleware era, the publish-and-subscribe MEP introduces a composite messaging model, comprised of primitive MEPs that implement a push delivery pattern. It establishes a unique relationship between service providers and service requestors where information is exchanged (often blindly) to achieve a form of dynamic notification (Figure 7.37).
Figure 7.37. Once subscribed, service A is notified of anything service B publishes that is of interest to service A.
While notification itself can be applied to different types of MEPs, the focus of this section is a discussion of notification within the context of the publish-and-subscribe pattern.
7.7.1. Publish-and-subscribe in abstract
As explained in Chapter 6, this messaging pattern can be classified as a complex MEP assembled from a series of primitive MEPs. It involves a publisher service that makes information categorized by different topics available to registered subscriber services. Subscribers can choose which topics they want to register for, either by interacting with the publisher directly or by communicating with a separate broker service. A topic is an item of interest and often is tied to the occurrence of an event.
When a new piece of information on a given topic becomes available, a publisher broadcasts this information to all those services that have subscribed to that topic. Alternatively, a broker service can be used to perform the broadcast on the publisher's behalf. This decouples the publisher from the subscriber, allowing each to act independently and without knowledge of each other.
In Plain English
Both our car wash company and our partner's are members of the World-Wide Car Washing Consortium (W3CC), an international organization dedicated to the advancement of the field of car washing. This organization issues weekly bulletins on a number of different topics. Members can sign up for the bulletins that are of most interest to them.
Our partner wants to stay informed with most of what occurs in the car washing industry, so they are registered to receive almost all of the bulletins. We are more interested in advancements relating to soap technology and sponging techniques. Our company, therefore, only subscribes to bulletins that discuss these topics.
Whenever industry developments (events) occur that we have expressed an interest in and for as long as our subscriptions are valid, bulletins (notifications) are sent to us (the subscribers).
7.7.2. One concept, two specifications
Two major implementations of the publish-and-subscribe pattern exist:
Spearheaded by IBM and Microsoft respectively, these use different approaches and terminology to cover much of the same ground. It is expected that a single publish-and-subscribe specification eventually will emerge as an industry standard. The remainder of this section is dedicated to exploring features of both specifications.
7.7.3. The WS-Notification Framework
As with other WS-* frameworks, what is represented by WS-Notification is a family of related extensions that have been designed with composability in mind.
To improve clarity, we take the liberty of breaking up some of the large concatenated terms provided in the WS-Notification specifications. For example, the term "NotificationMessage" in the WS-BaseNotification specification is expressed as "notification message" in this section.
Situations, notification messages, and topics
The notification process typically is tied to an event that is reported on by the publisher. This event is referred to as a situation. Situations can result in the generation of one or more notification messages. These messages contain information about (or relating to) the situation, and are categorized according to an available set of topics. Through this categorization, notification messages can be delivered to services that have subscribed to corresponding topics.
Notification producers and publishers
So far we've been using the familiar "publisher" and "subscriber" terms to describe the roles services assume when they participate in the publish-and-subscribe pattern. Within WS-Notification, however, these terms have more distinct definitions.
The term publisher represents the part of the solution that responds to situations and is responsible for generating notification messages. However, a publisher is not necessarily required to distribute these messages. Distribution of notification messages is the task of the notification producer. This service keeps track of subscriptions and corresponds directly with subscribers. It ensures that notification messages are organized by topic and delivered accordingly.
Notification consumers and subscribers
A subscriber is the part of the application that submits the subscribe request message to the notification producer. This means that the subscriber is not necessarily the recipient of the notification messages transmitted by the notification producer. The recipient is the notification consumer, the service to which the notification messages are delivered (Figure 7.38).
Figure 7.38. A basic notification architecture.
Notification broker, publisher registration manager, and subscription manager
To alleviate the need for direct contact between the two groups of services we described in the previous two sections, a set of supplementary services is available (Figure 7.39).
Figure 7.39. A notification architecture including a middle tier.
7.7.4. The WS-Eventing specification
As its name implies, WS-Eventing addresses publish-and-subscribe requirements by focusing on an event-oriented messaging model. When an event related to one Web service occurs, any other services that have expressed interest in the event are subsequently notified. Following are brief explanations of the terms and concepts expressed by the WS-Eventing specification.
The term "publisher" is never actually mentioned in the WS-Eventing specification. Instead, its role is assumed by a broader-scoped Web service, known as the event source. This part of the eventing architecture is responsible for both receiving subscription requests and for issuing corresponding notification messages that report information about occurred events.
Event sinks and subscribers
On the subscription end of the eventing model, separate Web services manage the processing of notification and subscription messages. An event sink is a service designed to consume (receive) notification messages from the event source. Subscribers are services capable of issuing various types of subscription requests.
An event source, by default, assumes the responsibility of managing subscriptions and transmitting notifications. In high volume environments it may be desirable to split these roles into separate services. To alleviate the demands on the event source, intermediate services, known as subscription managers, optionally can be used to distribute publisher-side processing duties.
Notification messages and subscription end messages
When an event occurs, it is reported by the event source via the issuance of a notification message (also called an event message). These are standard SOAP messages that contain WS-Eventing-compliant headers to convey event details.
WS-Eventing allows for an expiry date to be attached to subscriptions. This requires that subscribers issue renewal requests for the subscription to continue (as discussed in the next section). If a subscription is left to expire, though, it is the event source that often is expected to send a special type of notification to the corresponding event sink, called a subscription end message.
Subscription messages and subscription filters
Subscribers issue subscription messages directly to the event source or to an intermediate subscription manager. Different types of subscription-related requests can be transmitted via subscription messages.
The following specific requests are supported:
For a subscriber to communicate that the event sink (on behalf of whom it is submitting the subscription request) is only interested in certain types of events, it can issue a subscription message containing a subscription filter. If the event source does not support filtering (or if it cannot accommodate the requested filter), the subscription request is denied.
The relationships between the subscription manager, event source, subscriber, and event sink are shown in Figure 7.40.
Figure 7.40. A basic eventing architecture.
7.7.5. WS-Notification and WS-Eventing
The fact that these two specifications currently provide overlapping feature sets is no indication that this will remain so in the future. It has been speculated that the reason these specifications were created separately was because the individual sponsors had diverging requirements. One of IBM's goals is to incorporate WS-Notification with its grid computing initiatives. Microsoft, on the other hand, is expected to utilize WS-Eventing within its system administration platform.
In an effort to continue promoting interoperability across proprietary platforms, IBM recently joined the WS-Eventing effort. It is entirely within the realm of possibilities that either specification will be modified to align with the otheror that the vendors involved will come to an agreement on how to establish a single notification extension that will meet their collective requirements. Language descriptions for these two specifications are therefore not currently provided in this book. (If you are interested in viewing the individual specifications, visit www.specifications.ws.)
7.7.6. Notification, eventing, and SOA
By implementing a messaging model capable of supporting traditional publish-and-subscribe functionality, corresponding legacy features now can be fully realized within service-oriented application environments (Figure 7.41). Moreover, the ability to weave a sophisticated notification system into service-oriented solutions can significantly broaden the applicability of this messaging model (as evidenced by the before mentioned plans to incorporate notification with grid computing).
Figure 7.41. Notification and eventing establishing standardized publish-and-subscribe models within SOA.
Service-oriented solutions can increase QoS characteristics by leveraging notification mechanisms to perform various types of event reporting. For example, performance and exception management related events can trigger notification broadcasts to potential service requestors (subscribers), informing them of a variety of conditions.
In response to a series of complaints from vendors who experienced message transmission problems that resulted from changes to TLS service descriptions, TLS has decided to supplement their existing metadata exchange support by implementing a notification system. Now, business partners will be forewarned of any upcoming changes that might impact their systems.
There are many services that comprise the TLS B2B solution. Each performs a specific function that involves one or more types of partners. Not all partners need to interact with every TLS service. As a result, the notification system is set up in such a manner that partners are able to subscribe to notifications relating to specific TLS services or groups of services.
For this, TLS has provided a dedicated System Notification Service that acts as the publisher of notification messages. Partners are consequently required to implement their own subscriber services. Each notification message essentially requests that the recipient initiate a WS-MetadataExchange against the provided TLS endpoint(s).
RailCo creates a separate subscription service to interact with the TLS System Notification Service. Unfortunately, RailCo calls its new service the "TLS Subscription Service," which is sure to lead to confusion in the future. Regardless, RailCo uses its service to subscribe to and receive notifications relating to the two primary services with which it interacts on a regular basis: the TLS Accounts Payable and Purchase Order Services (Figure 7.42).
Figure 7.42. The new RailCo subscription service allows RailCo to receive notifications from the TLS System Notification Service.
SUMMARY OF KEY POINTS
Part I: SOA and Web Services Fundamentals
The Evolution of SOA
Web Services and Primitive SOA
Part II: SOA and WS-* Extensions
Web Services and Contemporary SOA (Part I: Activity Management and Composition)
Web Services and Contemporary SOA (Part II: Advanced Messaging, Metadata, and Security)
Part III: SOA and Service-Orientation
Principles of Service-Orientation
Part IV: Building SOA (Planning and Analysis)
SOA Delivery Strategies
Service-Oriented Analysis (Part I: Introduction)
Service-Oriented Analysis (Part II: Service Modeling)
Part V: Building SOA (Technology and Design)
Service-Oriented Design (Part I: Introduction)
Service-Oriented Design (Part II: SOA Composition Guidelines)
Service-Oriented Design (Part III: Service Design)
Service-Oriented Design (Part IV: Business Process Design)
Fundamental WS-* Extensions
Appendix A. Case Studies: Conclusion