Official NserviceBus Documentation
The NServiceBus Host
Profiles for the Generic
Host
Our Deployment Details
Version: NServiceBus v2.0 RTM
OS: Windows 2003 Server
App Type: Windows Service
Host: NServiceBus.Host.exe
Subscription Storage: MSMQ
Our Goal
We have just created a new publisher service and it has taken a bit of time to understand exactly how to deploy it so that subscriptions were persisted after the service is restarted.
Out of the box NServiceBus has three options for storing subscription data, Memory, MSMQ or Database.
To use MSMQ you must either create your own custom profile that configures subscriptions to be stored in MSMQ or you must select Integration from the default profiles.
Regardless of the choice you make you must specify the profile you wish to use when you install the windows service, here is how you do that:
Basic Integration Example:
NServiceBus.Host.exe /install NServiceBus.Integration
Advanced Production Example:
NServiceBus.Host.exe /install NServiceBus.Production /serviceName:MyService /displayName:MyDisplayName/description:MyDescription /username:DOMAIN\username /password:MyPassword
To check the service has been setup correctly you can go and look in the properties of the service and check the text at the end of the “Path to executable” field. The example in the screenshot below shows the service is configured to use the Lite profile.
We had one more gotcha our implementation was copy/pasted from one of
our existing v1.9 services so we had to remove the .MsmqSubscriptionStorage()
option from our config. Now our endpoint config looks like thispublic void Init() { NServiceBus.Configure.With() .DefaultBuilder() .XmlSerializer() .MsmqTransport() .IsTransactional(true) .PurgeOnStartup(false) .UnicastBus() .ImpersonateSender(false) .CreateBus() .Start(); }The Default Profile’s Subscription Storage
Note: – If you select Production profile you may need to enable some settings inside MSDTC (in Component Services) if your database is on another server.
– If you are installing on to a machine that has UAC enabled you must run the install from a cmd prompt with elevated priviledges (Run As Administrator)

