Home > Architecture, NService Bus, Service Oriented Architecture, SOA > NServiceBus: The Magic of Generic Host

NServiceBus: The Magic of Generic Host

I have done a few posts on NServiceBus and have talked in great details about how it works with messages and MSMQ. However I haven’t talked much about the Generic Host and today’s post is just about that.And hope you will find quite amazing and valuable for your SOA development.

As you had seen in my previous post that it is a means to host your NServiceBus application, whether it’s the client sending a message to the bus or the server reading the message from the queue they both are assemblies and are hosted in this executable called the “Generic Host Process” for NServiceBusIt is this host which takes of wiring up messages, handler and endpoints to MSMQ etc.

When we run the generic host using command line we can see some interesting options as shown below.

NServiceBus Generic Host options

This means that you can configure any message endpoint as a Windows Service and Generic host will take care of installation. You don’t have to do a windows service host application, installer etc. All the plumbing and hard work is taken care by the generic host and you have to focus on writing your messages,message handlers and endpoints.

Let’s try installing the server component in the Full-Duplex sample as a windows service.

Installing NServiceBus component as a windows service

The Command Line:

NServiceBus.Host.exe /install /serviceName:MyServer.dll
/displayName:"My Super Duper service"
/description:"My server installed by NService Magic"

As you can see the command line is very self-explanatory, we have an assembly called MyServer.dll which implements a handler of a specific type and we want it’s display name to be My Super Duper Service and the description to be My server installed by NService Magic.

Lets verify this by opening the Windows Service Management Console and we can see our NServiceBus Server component installed as a windows service. When i did this for the first time it was not less than a magic.

Viewing service in windows services management console

To test whether it is doing what it is supposed to do I am going to run the Client only project from Visual Studio and our message gets picked by the windows service and our handler processes it successfully.

That’s it for now and I hope you guys will find a lot of value in using NServiceBus 🙂

Advertisements
  1. Eugene
    September 26, 2014 at 10:08 pm

    Hi there, just wanted to mention, I enjoyed this blog post.Keep on posting!

  1. December 31, 2012 at 10:48 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: