Services Are Not Objects

Many .NET applications I see that have a so-called Service-Oriented Architecture (SOA) use a technology such as Windows Communication Foundation (WCF) to treat services as if they were local objects. You call methods on the remote object in the same way as you would call a local object, only rather than executing locally, the request is sent to a remote service for processing which may then return a response. This is known as a Remote Procedure Call, or RPC. Often these calls can cause the application to hang while waiting for a response. The usual way to handle this is to call the service method asynchronously, providing a method to call when a response comes back. This allows your application to continue processing after the request is made.

Sounds simple enough, but I have found these direct request-response calls can lead to a fragile and unreliable application that is tightly-coupled to the services it calls. If for some reason a service is not available, your application may stop functioning. Sure, you can build in error-handling, but it then becomes the responsibility of your application to manage the dependency on the service.

Recently, Jennifer Smith and I were discussing the unreliable nature of these architectures on Twitter, when Udi Dahan, SOA specialist and creator of NServiceBus, pointed us to a recent blog post of his that explains why we shouldn’t call services as if they were real objects. Udi suggests that there is a better way to handle calls to services and that is to use a message queue. He also makes the point that we need to stop treating services as local objects and use messaging as in integral part of the application architecture:

A queue isn’t an implementation detail. It’s the primary architectural abstraction of a distributed system.

So, if you’re developing a distributed application, use a message bus to communicate between applications. The message bus is responsible for transporting messages between applications. When you use a message bus, the application that sends a message is no longer coupled to the receiver.

I am currently converting a fragile request-response service-based application to use messaging with the NServiceBus message bus. I hope to significantly improve the performance and robustness of the application by making messaging a first-class citizen in the architecture, and not just an abstraction.

For more information on messaging and NServiceBus, check out:

This book also contains excellent information on designing and developing messaging solutions:


4 Responses to “Services Are Not Objects”

  1. 1 Udi Dahan June 7, 2009 at 6:28 am


    Glad to hear things are making sense for you.
    If you do run into issues, please bring them to the discussion group where many have found answers in the archives already:

    You can also register yourself on the community site and read some reviews and links people have shared on their experiences with nServiceBus:


  2. 2 timross June 7, 2009 at 3:22 pm

    Hi Udi, I’ll definitely check out those sites, thanks!

  3. 3 Jen June 8, 2009 at 4:20 pm

    Hey Tim,

    Great you are able to replace said flaky WCF architecture with a message bus/ NServiceBus framework.

    I have had a look (very briefly) at a couple of message bus frameworks and I believe it solves a lot of the problems we try to solve with WCF and its brethren. I think it is gaining mileage in a lot of communities – it’s just that a lot of us don’t really understand a lot of the concepts!

    If I had time/energy I would request a nice free SkillsMatter evening or something….

  4. 4 timross June 8, 2009 at 4:54 pm

    Hi Jen, there is certainly a lot to learn. I have just purchased an early-access version of a book called SOA Patterns that looks really good. But yes, an evening of ESB’s with SkillsMatter would be great!

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: