Home > Articles > Web Services > SOA

SOA Pattern (#11): Event-Driven Messaging

  • Print
  • + Share This
The Event-Driven Messaging design pattern attempts to address the inefficiencies related to the use of the traditional polling based model by suggesting a publisher-subscriber based model whereby a service interaction occurs only when an event occurs within the boundary of the service provider.
Like this article? We recommend

Like this article? We recommend


A service composition might be designed such that a service consumer is dependent upon the occurrence of an event within the boundary of a service provider. Polling the service provider in this case would not only make the service composition inefficient but would also make it prone to behavioral unpredictability as a service consumer might not be able to poll the service provider in a way that ensures an event would not be missed. At the same time, as the service consumer becomes directly dependent on the service provider, this periodic polling increases the coupling between the service consumer and the service provider. This in turn affects the individual autonomy of the service consumer as well as the overall autonomy of the service composition. On the other hand, it also affects the service provider in a negative manner in that the service provider is constantly involved in responding to fruitless service interactions.

Having its roots strongly embedded within the object-oriented design paradigm, the service-orientation design paradigm provides the Event-Driven Messaging pattern that is based on the Observer pattern, which works on the basis of a publisher-subscriber model. Although a solution to the issues discussed within the preceding paragraph could be based on the application of the Service Callback design pattern, it still does not allow the service consumer and the service provider to be completely decoupled from each other. Therefore, in order to fully decouple the service consumer and the service provider, the application of the Event-Driven design pattern dictates the use of an event manager that is tasked with event registration as well as automatic event notification. This not only increases the behavioral predictability of the service composition, but also increases its reliability as the event manager makes sure that the subscribed service consumers do not miss any event notifications. The application of this pattern further increases the recomposability level of the service provider as a service that guarantees provisioning of event notifications as and when an event occurs, manifests higher behavioral predictability; therefore, it is bound to be composed repeatedly.

It should be noted that the application of the Event-Driven Messaging pattern requires support from the underlying platform that implements the publisher-subscriber based mechanism. This might incur extra costs in the form of acquisition of architectural extensions (for example, an ESB), if the underlying platform does not already provide such a mechanism. This would further impact the service inventory architecture and the service composition architecture as these architectures would require modifications in order to support the application of the Event-Driven Messaging pattern. In order to minimize any disruptions caused by the application of this design pattern, it is better to identify the need for such architectural extensions as early as possible. Therefore, during the service-oriented analysis phase of the service delivery process, all the services that provide event-based capabilities need to be identified so that the underlying architecture can be upgraded accordingly in advance.

Although the application of the Event-Driven Messaging pattern does address the issues linked with polling based service interactions, it should be noted that because of the asynchronous nature of the message exchange between the service provider and the service consumer, it would be rather difficult to employ such services in a service composition that requires the use of atomic transactions, thereby making the application of the Atomic Service Transaction design pattern somewhat impossible. Similarly, as it cannot be guaranteed that the service consumer has in fact received all the event notifications, it is vital to apply this design pattern along with the Asynchronous Queuing and the Reliable Messaging design patterns for a guaranteed delivery of event notification messages.

It is quite clear from the discussion above that the Event-Driven Messaging design pattern helps to establish an efficient and a reliable messaging system between the service consumers and the service providers; however, it is important to keep in mind the additional costs linked with its application and the impact on the existing service inventory and the service composition architectures.

The SOA Pattern of the Week series is comprised of original content and insights provided to you courtesy of the authors and contributors of the SOAPatterns.org community site and the book “SOA Design Patterns” (Erl et al., ISBN: 0136135161, Prentice Hall, 2009), the latest title in the Prentice Hall Service-Oriented Computing Series from Thomas Erl (www.soabooks.com).

  • + Share This
  • 🔖 Save To Your Account