Service Anti-Patterns, Command vs. Document Message
Via Arjen, Service Pattern and Anti-Patterns. While reading this article last night I got sucked into thinking about using a Document Message pattern:
1.)
[WebMethod()]
public FindCustomersByCountryResponse FindCustomersByCountry(FindCustomersByCountryRequest request)
{
..
}
vs a Comand Message pattern.
2.)
[WebMethod()]
public Customer[] FindCustomersByCountry(string country)
{
..
}
or
3.)
[WebMethod()]
public Customer[] FindCustomersByCountry(Country country)
{
..
}
Although EIP gives very clear guidance on when to use what, my experience is that most services based on Web Services technology use the Command Message pattern where services based upon MQ technology make good use out of both Message pattern styles. Why is that? Given the fact that services are build to last, I think I prefer, in the context of a Web Service, Document Messages and explicitly design a request/reply messages as if it is a Command Message. …and stay away from option 2 altogether.
Any thoughts?