What is mediation and why is it important?
Service-oriented architecture is fundamentally about integrating distributed systems. Those distributed systems communicate using messages. Typically these messaging systems can be thought of as e-mail for applications instead of people. This short technical tip will describe a few of those messaging options and explain how you can get a more flexible, reactive and manageable infrastructure by adding smart mediation to that messaging.
Mediation is simply the act of adding extra processing to those messages without disrupting the existing applications at each end. To give a really simple, but powerful example, look at Web caching proxies. These sit between a browser and the Web server and, without changes to the browser or server, can significantly speed up Web interactions. They do this by intercepting calls to the server and, if possible, responding with previously cached responses. A good example of a Web caching proxy is
Being able to mediate messages requires that the mediation system knows the format and protocol of those messages. For example, the Web caching proxy relies on the messages using the HTTP protocol. Typically service-oriented architectures use on of the following messaging styles:
- HTTP – a number of people use HTTP as a simple messaging format. For example, sending XML messages over HTTP is simple and usually easy to interoperate.
- SOAP – SOAP is an XML messaging format that allows for many extensions, including Security and Reliable Messaging. SOAP is fundamentally designed to be an interoperable protocol, but some of the newer aspects can be complex to get working across different implementations.
- JMS – JMS is not a messaging protocol, but instead a standard programming model in Java that supports different underlying messaging protocols. Usually those protocols are specific to the particular JMS implementation.
- Traditional message queuing – for example, IBM WebSphere MQ/MQSeries™. These use proprietary protocols, but usually offer support for a wide variety of platforms and systems.
There are an important class of mediations that do not rely on understanding the contents of the message. For example, the caching model does not rely on the cache understanding the Web page content – instead it relies on standard headers that indicate which pages can be cached and for how long. Another good example of a cross-cutting mediation is logging. It is simple to deploy a logger that logs each message, the time and destination.
Further examples of cross-cutting mediation include:
- Encrypting and decrypting messages
- Redirection and routing
- Message storage
- Load-balancing and failover
Service orientation is an extension to message orientation
Message-based interactions have been around for a long time. What is the key differentiator between a message-based system and a service? Fundamentally it is about using open content as well as open protocols. For example, not only do SOAP systems use XML as a message content format, but there is also a model ( Web Services Description Language – WSDL) that allows you to associate XML Schemas to service messages. This is important for mediation, because now we can start to mediate based on message content as well.
Message-based mediations include:
- Content based routing – for example re-routing orders worth more than $100,000
- Transformation – for example using XSLT to re-order or transform XML messages
- Converting between message styles – for example from CSV to XML
A simple example of mediation
One of the key benefits of mediation can be summed up by the words "divide and conquer.". In other words, solve different problems in different places. Here is a simple example. Suppose you already have a simple XML/HTTPS message-based service, but your security team would like you to use the WS-Security protocol to add digital signatures. One option would be to take the existing XML/HTTP application and rewrite it or reconfigure it to run in an environment that supports SOAP and WS-Security.
Unfortunately this can be a time consuming activity. Mediation offers a simpler solution – add an intermediary that manages the WS-Security and SOAP processing and then passes the XML body to the existing application. This can dramatically reduce time, especially compared to rewriting existing working code. Systems that support this form of mediation include hardware appliances from Reactivity (acquired by Cisco Systems Inc.) and Datapower (acquired by IBM), and open source software solutions such as Apache Synapse.
About the author
Paul Fremantle is vice president of technical sales at WSO2, an open source SOA integrator. He also is co-chair of the OASIS WS-RX Technical Committee and a project leader for Apache Synapse.
This was first published in December 2007