nServiceBus NServiceBus training - opens a new tab
 
  Overview Documentation Downloads Community Roadmap License
 

NServiceBus and WCF

Is there a question?

The main thing missing from WCF is pub/sub,
and why should you have to build it yourself?
With NServiceBus, you get it out of the box.

The next important thing is fault-tolerance.

Exceptions cause WCF proxies to break,
requiring you to "refresh" them in code
but the call data is liable to be lost.

NServiceBus provides full system rollback.
Not only does your DB remain consistent,
but your messages return to their queues too
and no valuable data is lost.

The same goes for plain MSMQ

Whether you're looking at the MSMQ bindings for WCF or programming directly against MSMQ, in both cases you end up having to handle pub/sub and the transaction & exception management needed for full fault tolerance. The other area that you're left to handle with MSMQ is long-running processes.

Here's what one CIO had to say:

Karell Ste-Marie, CIO of BrainBank Inc
"I have to say this: nServiceBus is an incredible product, I only wish there was a bit more documentation on it – we see it being used in so many places in our own software (not just queued processing, which is what we are trying to quickly patch right now) and is taking us in new directions. We have been working on a WCF approach for 45 days until we threw it away and replaced it all with nServiceBus and got it working @ 99.99% in 7 business days.

Thank you for creating this great framework"
Karell Ste-Marie, CIO of BrainBank Inc

Long-running processes

WCF integrates with WF in order to provide a capability known as durable services. WF provides the state management facilities that are hooked into the communication facilities provided by WCF. Unfortunately, transaction and exception boundaries aren't specified by the infrastructure.

Unless developers are very careful about how they connect workflow activities, transaction scopes, and communications activities, process state can be corrupted and exposed to remote services and clients. One of the reasons this is possible by design is that WF is designed as a generic workflow engine, not specifically for long-running processes.

Since regular business logic is simple and stable enough on its own, NServiceBus has been specifically designed to handle long-running processes in such a way that they are robust and scalable by default - without developers having to do anything special.

Transactions are automatically handled on a per-message basis and inherently span all communications and state-management work done by an endpoint. An exception causes all work to be undone, including the sending of any messages - so that remote services and clients do not get exposed to inconsistent data.

Interoperability

You can expose your NServiceBus endpoints as WCF services with as little as one line of code and the standard WCF configuration. All you need to do is write an empty class that inherits from NServiceBus.WcfService specifying the types of the request and the response and NServiceBus does the rest as follows:

public class MyService : NServiceBus.WcfService<MyCommand, MyErrorCodes> { }

With NServiceBus, you get access to the features you need from WCF like interoperability without giving up the reliability and scalability of messaging.


See how easy publish/subscribe messaging can be with NServiceBus: Download Now

NServiceBus is managed and run by Udi Dahan.
Committers include Andreas Öhlund and Matt Burton.

All content on this site is licensed under the Creative Commons Attribution License.