Grok’ing nServiceBus

First read this nServiceBus overview.

I’m recording my learning so I can refer to it later.

Messaging Concepts


For messaging to work you need to transport messages from one endpoint to another, once an application has created the message addressed it and put it into a queue it is up to the transport to attempt delivery. MSMQ is the default choice of nServiceBus.

Command Query Separation (CQS)

Wikipedia describes CQS as a pattern where “… every method should either be a command that performs an action, or a query
that returns data to the caller, but not both. More formally, methods
should return a value only if they are referentially transparent and
hence possess no side effects.”
Udi Dahan’s Blog Post on CQS

The Cost of Messaging

Using a messaging approach to building systems offers lots benefits that other approaches don’t but you rarely get something for nothing, Ayende’s article discusses the cost of messaging.

nServiceBus Concepts

Publish vs Send – Wiki Article

The Distributor

The distributor as it’s name suggests distributes work to be done to worker services. This avoids the need for the service that decides what work is to be done from having to contact all workers or have logic that handles balancing the work load.
Worker services inform the distributor how many idle threads they have available and it dispatches the same number of jobs. When a thread completes the distributor is notified so that if any jobs are in the work queue one will be sent.
This means an administrator can monitor the work queue to see if there are enough workers to handle the load.

nService Bus Code Samples Articles

Synchronous Web Service Bridge – Udi Dahan

Pub / Sub Walkthrough – Erik Westermann

Useful info for beginners – Matt Salmon

Installation and Config

Wiki Article on configuration

Getting started article on Art of BabelErik Westermann

Reviews of nServiceBus

Ayende Rahien’s Review and his review of the distributor

nService Bus Info on the Web

Mailing List on Yahoo Groups

Udi’s FAQ on the nServiceBus Website – Full of programming tips

Case Studies and Scenarios for Usage

Asynchronous High Performance Login Example – Udi Dahan


New packaging for NServiceBus 2.0

The link above is to Andreas Ohlund’s blog post that explains the differences between the packaging for version 1.9 and 2.0
The main difference in the introduction of a nServicebus.core.dll and nServiceBus.Host.exe

Hosting NServiceBus in IIS

Change this:




from Mike Dellanoce’s Blog Post

Install an SSL cert on your local machine for testing

One of the devs in our team here came accross this useful tool.

If you find the need to install an SSL cert on your
local machine for testing purposes, such is the requirement for testing the
API, you can download the IIS 6.0 Resource Kit Tools from Microsoft, which
contains a tool called SelfSSL.

This is a simple command line utility which will install an ssl cert on

the tool kit can be downloaded from here:

How MSMQ works

I found a this great analogy on how MSMQ works

URL : Full MEssage

“MSMQ works similar to how USPS works.


write your letter, write in address (queue format name), attach stamp
and put it into your mail box with raised red flag (send the message
using MSMQ).

mail (message) then sits in this mail box near your house (outgoing
queue). Note at that point you can get address wrong on your letter
(bad format name), however that won’t stop you from putting letter into
mail box (sending it).

so later one mail man comes (network connection is established). Mail
man picks your mail (MSMQ connects to the destination server) and if
everything is OK it goes through the system (network) and ends up in
receiving mail box (destination queue). Recipient (your application on
the server) don’t have to be near (don’t have to be running) this mail
box (queue) for mail to arrive.

some point somebody (your application) opens mail box (application on
the server reads from the destination queue) and gets mail.

could go wrong here? Well, you can get address wrong. Mail man can
never come (no network connection on device). Destination might be
inaccessible, say avalanche blocked the roads (server is down or no
network path to it) or there’s civil disturbance and it’s blocked out
by the police (firewall or security configuration prevents connection
to the server).

Another thing: I’m not absolutely sure, but you might have to install web server and configure MSMQ ISAPI DLL for SRMP to work.”