Friday, March 18, 2011

NServiceBus Customization, Let me Count the Ways!

So as promised I'm going to start a new series on customizing the behaviour of NSB. I figured that we'd first try to count up all the ways to do it and then tackle each one by one. I'm going to categorize them by when they occur during the NSB lifetime, Startup, Processing, and Shutdown.  I'm not going to include everything(it would take forever), but I'm going to include the most popular places where you'd customize.


  • IWantCustomInitialization - take over control of how the bus is initialized, skipping Roles
  • Roles - AsA_* interfaces. Control how the bus is initialized.
  • IWantToRunAtStartup - run a custom action once at startup
  • IConfigureLoggingForProfile<T> - configure logging for a specific Profile
  • Profiles - IProfile. Determine settings for a given target environment. OOTB includes "Lite", "Integration", and "Production"
  • ISpecifyMessageOrderHandling - creates a "pipeline" of messages and gives them a specific order
  • The Container - you can pretty much change anything in the container, including passing in your own that is loaded with your stuff.


  • IMessageMutator - manipulate inbound and outbound messages
  • IMessageModule - inject some logic before and after message processing
  • IManageUnitsOfWork - UOW pattern handling
  • IManageMessageFailures - custom failed message handling
  • Processing Events - StartedMessageProcessing, TransportMessageReceived, FinishedMessageProcessing, FailedMessageProcessing.  You can use these to do something when message events are happening(say perf counters)


  • IWantToRunAtStartup - there is a Stop method here that gets called once during shutdown

No comments:

Post a Comment