The NServiceBus Host profiles are ways for you to alter the behavior of your endpoint without recompiling your code.
The profiles enables tailoring endpoints for different environments and controlling things like scaling out (running the distributor) and enabling HTTP access (gateway).
Profiles are only available if you use the NServiceBus host (NServiceBus.Host.exe or the 32 only version of it) so this is not applicable if you self host NServiceBus inside a website, WCF service, smart client etc.
Profiles can be divided into 2 main categories depending on what they control:
Environment Profiles The Environment profiles helps to avoid the error prone manual configuration that is required when moving a system from Development to Production via Integration.
Environment profiles enables easy transition of the system without any code changes.
Feature Profiles Easily and without code changes turn on an off NServiceBus features. For example, turning on and off the Distributor, Gateway and timeout manager.
Technically there is no difference between the Environment and the Feature Profiles.
Lets have a closer look at each one of them, starting with the Environment profiles.
Environment related profiles
NServiceBus comes with 3 built-in profiles who’s main goal is to adjust the behavioral of the host depending on the environment where the endpoint is running.
You can of course create your own profiles, more on that can be found here.
The 3 environmental profiles are:
Lite This profile is suitable for running on your development machine possible inside visual studio.
This profile configures all the persistence like sagas, subscriptions, timeouts etc to be InMemory which is easy setup but probably not what you want for production.
Lite also turns the TimeoutManager and Gateway on by default.
Installers are always invoked when running the lite profile.
Logging is done to the console.
Integration The integration profile is suitable for running your endpoint in an integration and QA environments.
Storage is persistent using queues or RavenDB.
Features like TimeoutManager and Gateway are now turned off be default.
Installers are still being invoked to make deployment easier to automate.
Logging is still being output to the console by default.
Production This is the default profile that is used if no explicit profile is defined.
This profile sets your endpoint up for production use.
This means that all storage is durable and suitable for scale out.
Installers are not invoked since your endpoint will probably be installed as a windows service and not running with elevated privileges.
Installers are only run when you install the host or you are running inside Visual Studio in Debug mode.
Logging is done to a logfile in the runtime directory since again you’re most likely running as a windows service.
Performance counters are installed by default.
Feature related profiles
The feature related profiles that comes out of the box are:
MultiSite Turns the the gateway on
Master Makes the endpoint a “master node endpoint”.
This means that it will run the Gateway for multisite interaction, Timeout manager and the Distributor.
It will also start a worker that will enlist with the Distributor.
The Master profile can’t be combined with the Worker or Distributor profiles.
Worker Makes the current endpoint enlist as a worker with its distributor running on the master node.
Can’t be combined with the Master or Distributor profile.
Distributor Starts the endpoint as a distributor only.
This means that the endpoint won’t do any actual work and only distribute the load among its enlisted workers.
Can’t be combined with the Master and Worker profiles.
PerformanceCounters Turns the NServiceBus specific performance counters on.
Performance counters are installed by default when running in Production profile.
Telling the host which profiles to run
To activate a specific profile just pass the full name of the profile on the command-line when starting the host.
Type names are case insensitive.
Profiles can be combine by separating them with a white space.
So if you want your endpoint to run in the Integration and Master profiles you would use the following:
.\NServiceBus.Host.exe nservicebus.integration nservicebus.master
When you install the host as a windows service the profiles used when installing will be persisted and used every time the host starts.
So if you want to install your host with the Production and the MultiSite profiles you would use:
.\NServiceBus.Host.exe /install nservicebus.production nservicebus.multisite