Yesterday we learned how to create a small ASP.NET MVC 2 application which uses the NServiceBus as its server. Also we learned how to extract the user name of the message’s sender in a message handler. Today we’re going to try out what happens to the client if the server is down.

Take the application we built yesterday and start the client. Make sure that the server isn’t running. Click on the “Send hello” few times and notice that the software seems to be working normally. This is because the call from our HomeControl to the NServiceBus is asynchronous. The web client doesn’t have wait for the server to answer. Now imagine that we’re using a real web application and user fills some information and sends the message to the bus. What the user doesn’t know is that the server has just crashed so there’s now one handling the calls from the queue. Was the user’s work lost? You can start your server to find out.


As you can see, the answer is no. NServiceBus uses the Store & Forward Messaging model where the client just passes the message to the messaging system and then the client is free to continue its own work. It’s up to the messaging system to deliver the message to the right destination. You can find more information about this model from the links provided in the end of this post.

Close the server again and click the “Send hello” few more times. Let’s use Windows’ own tools to visualize what is happening. Remember how we configured our client to use the InputQueue as our HelloWorldMessage’s endpoint? Good, because it’s that queue which is holding our messages until we start our server again.

Internally, NServiceBus uses MSMQ-queues when working with the messages. The operating system includes a software which can be used to monitor the MSMQ-queues. If you’re using Windows 7 or Windows Vista (sorry, I don’t have instructions for you Win XP users), you can start up your Computer Management –application. From there, browse to “Services and Applications” - “Message Queuing” - “Private Queues”. Your view should look similar to the following screenshot:


There’s our messages! If you now start your server, you should see how the messages are processed. If you switch back to the Computer Management and hit F5, your inputqueue is again empty.


Designing you application around a messaging system like NServiceBus allows the client application to work even if your server goes down for a moment. Also, if your messages seem to be disappearing before they reach the server, you can use Windows’ own tools  to browse through your message queues.