This article by Ian Robinson of ThoughtWorks discusses some of the challenges in evolving a community of service providers and consumers. It describes some of the coupling issues that arise when service providers change parts of their contract (particularly document schemas) and identifies two well-understood strategies – adding schema extension points and performing “just enough” validation of received messages- – for mitigating such issues.
Both strategies help protect consumers from changes to a provider contract, but neither of them gives the provider any insight into the ways it is being used and the obligations it must maintain as it evolves. Drawing on the assertion-based language of one of these mitigation strategies – the “just enough” validation strategy – the article then describes the Consumer-Driven Contract pattern, which imbues providers with insight into their consumer obligations, and focuses service evolution around the delivery of the key business functionality demanded by consumers.
A brief note on terminology: provider and consumer are roles that services adopt in their interactions with other services. A service may act as provider of business functionality in one set of interactions, but consumer in another. Neither role limits a service from fulfilling the orthogonal roles of sender and receiver: as a provider in a request-response interaction, a service will act first as a receiver, and then as a sender.
Evolving a service: an example
To illustrate some of the problems we encounter while evolving services, consider a simple ProductSearch service, which allows consumer applications to search our product catalogue. A search result has the following structure:
An example search result document looks like this:
<?xml version=”1.0” encoding=”utf-8”?>
<Products xmlns=”urn:example.com:productsearch:products”>
<Product>
<CatalogueID>101</CatalogueID>
<Name>Widget</Name>
<Price>10.99</Price>
<Manufacturer>Company A</Manufacturer>
<InStock>Yes</InStock>
</Product>
<Product>
<CatalogueID>300</CatalogueID>
<Name>Fooble</Name>
<Price>2.00</Price>
<Manufacturer>Company B</Manufacturer>
<InStock>No</InStock>
</Product>
</Products>
