Bloggin in the UK RSS 2.0
 Tuesday, April 20, 2010

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 this

public 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)


Tuesday, April 20, 2010 2:08:25 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
nServiceBus
 Monday, March 08, 2010



We have been using nServiceBus in production for over 6 months now, we have had a very positive experience, so I wanted to show how we have been using it with some real world examples. One implementation we have just released handles inbound SMS messages and checks the sender's number to see if they are an existing or new customer then reacts accordingly.




1) Our SMS provider calls our http handler (hosted in IIS) each time an inbound SMS is recieved.
2) The http handler calls the SmsGateway via a WCF service, which in turn publishes an InboundSmsMessage to the bus.
3) The Subscriber receives the InboundSmsMessage it interrogates the database to see if this is an exising customer or not.
4) Finally is sends a command to the worker service depending on whether this is an existing customer or not.
5) If the SMS is not from an existing customer then the worker initiates a call between the number and a CS agent.

Benefits of this approach

If their is a sudden surge in inbound Sms messages due to a successful advertising campaign we can control processing to avoid degrading overall system performance. We could further isolate our message processing from the core system by creating a cache on the Subscriber of all existing customer's mobile numbers. This cache could be kept up to date by the publishing new customer messages.

If other services need to know about inbound SMS message say for invoice reconcilliation or just marketing reports they can subscribe to the messages and aggregate them. This can be done in realtime to allow the marketing team access to a dashboard that provides feedback on the effectiveness of their campaigns.

The most obvious benefit is that the Sms Gateway is autonomous, and the services that subscribe to the inbound messages need no understanding of what an SMS message is or it's semantics.

UPDATE:
We have since realised that our implementation is not optimal, we are going to host NServiceBus in IIS and send and Inbound message notification to the SMS Gateway service and remove the WCF piece.


Monday, March 08, 2010 4:08:52 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
nServiceBus
 Monday, April 20, 2009
First read this nServiceBus overview.

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

Messaging Concepts

Transport

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 Babel - Erik 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

Update:

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:
NServiceBus.Configure.With()...
to:
NServiceBus.Configure.WithWeb()...
from Mike Dellanoce's Blog Post

Monday, April 20, 2009 9:05:59 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
nServiceBus
Archive
<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010
Charlie Barker
Sign In
Statistics
Total Posts: 169
This Year: 11
This Month: 2
This Week: 0
Comments: 77
Themes
Pick a theme:
All Content © 2010, Charlie Barker
DasBlog theme 'Business' created by Christoph De Baene (delarou)