The NServiceBus Host profiles enable altering the behavior of an endpoint without recompiling the code. The profiles enable tailoring endpoints configuration for different environments.
Profiles are only available if using the NServiceBus host (NServiceBus.Host.exe or the 32-bit only version of it) so this is not applicable if self hosting NServiceBus in a website, WCF service, smart client, etc.
Profiles are divided into two main categories, depending on what they control:
- Environment profiles help to avoid common configuration errors that occur when manually moving a system from development to production via integration. Environment profiles enable easy transition of the system without any code changes.
- Feature profiles turn NServiceBus features on and off, easily and with no code changes. For example, turning on and off the performance counters.
Technically there is no difference between the environment- and feature-related profiles.
NServiceBus comes with three built-in profiles whose main goal is to adjust the behavior of the host, depending on the environment where the endpoint is running.
It is possible to create custom profiles.
The environmental-related profiles:
Suitable for running on the development machine, possibly inside Visual Studio.
Installers are always invoked when running the Lite profile.
Suitable for running the endpoint in integration and QA environments.
Installers are invoked to make deployment easy to automate.
The default if no explicit profile is defined.
This profile sets the endpoint up for production use.
Installers are not invoked since the endpoint is probably installed as a Windows Service and does not run with elevated privileges.
Feature-related profiles that come out of the box:
PerformanceCountersturns on the NServiceBus performance counters.
To activate a specific profile, when starting the host, pass the full name of the profile in the command line. Type names are case insensitive. Profiles can be combined by separating them with white space.
For example, to run the endpoint with the
.\NServiceBus.Host.exe nservicebus.integration nservicebus.performancecounters
When installing the host as a Windows Service, the profiles used during installation are saved and they are used every time the host starts. In order to install the host with the
.\NServiceBus.Host.exe /install nservicebus.production nservicebus.performancecounters