Self hosting

Component: NServiceBus
NuGet Package NServiceBus (5.x)

Code walk-through

This sample shows how to host an in-process instance of NServiceBus.

var busConfiguration = new BusConfiguration();

using (var bus = Bus.Create(busConfiguration).Start())
    Console.WriteLine("\r\nBus created and configured; press any key to stop program\r\n");
    var myMessage = new MyMessage();
Although not shown in this sample, when self-hosting NServiceBus, the critical error action should always be overridden. If a critical error occurs, NServiceBus will stop the endpoint but will not shut down the process. By specifying a critical error action, the host application can elect to terminate in order to be respawned, or take action to notify system administrators of the failure.

Related Articles

  • Hosting
    Describes the various approaches to endpoint hosting.

Last modified