NServiceBus allows you to configure the host process by implementing specific interfaces that it will find when performing assembly scanning on startup. This includes two configuration interfaces, IConfigureThisEndpoint
and INeedInitialization
, that define a Customize
method, which gives you access to the BusConfiguration
instance, and an IWantToRunWhenBusStartsAndStops
endpoint startup interface, which allows you to perform nonconfiguration startup tasks.
Let's take a look at these interfaces in the order in which they are executed.
We have already seen this interface, as the single class that implements it (commonly called the EndpointConfig
) defines an endpoint hosted by the NServiceBus Host process. When the host process starts up, it scans all the assemblies in the runtime directory for this interface, and when it's found, NServiceBus gives the class implementing it the first chance to configure NServiceBus through the BusConfiguration
object...