NServiceBus Host profiles

Component: NServiceBus Host | Nuget: NServiceBus.Host (Version: 4.x)
Target NServiceBus Version: 4.x
Standard support for version 4.x of NServiceBus has expired. For more information see our Support Policy.

There are many configuration options for endpoints using NServiceBus Host. The endpoint configuration specifies levels of logging, subscription and saga storage, etc.

Profiles enable tailoring endpoints configuration for different environments without recompiling code.

There are two categories of profiles:

  • Environment profiles can be used to avoid common configuration errors that occur when manually moving a system between different environments, e.g. from development to production.
  • Feature profiles allow to turn on and off NServiceBus features such as performance counters with no code changes.

Default profiles

NServiceBus out of the box comes with a set of predefined environment and feature profiles. It's also possible to create custom profiles or customize the default profiles, to learn more about those options refer to the NServiceBus Host Profiles customization article.

Environment profiles

There are three built-in environment profiles that adjust the behavior of the host to the environment in which the endpoint is running. These profiles can be used to easily switch between different environments during development, testing and deployment.

Lite profile

Suitable for running on the development machine, possibly inside Visual Studio.

  • InMemory persistence is used for storing information like sagas, subscriptions, timeouts, etc. That is a convenient option for development, but should not be used in production.
  • The Lite profile by default turns on the TimeoutManager.
  • Installers are always invoked when running the Lite profile.
  • Logging is output to the console.

Integration profile

Suitable for running the endpoint in integration and QA environments.

  • Installers are invoked to make deployment easy to automate.
  • Logging is output to the console by default.

Production profile

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. Installers only run when installing the host or the code runs inside Visual Studio in Debug mode.
  • All configured storage is durable and suitable for scale out.
  • Logging is output to a log file in the runtime directory.
  • Performance counters are installed by default.

Feature profiles

  • Master makes the endpoint a "master node endpoint". This means that it runs the gateway for multi-site interaction, the timeout manager, and the Distributor. It also starts a worker that enlists with the Distributor. It cannot 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. It cannot be combined with the master or distributor profiles.
  • Distributor starts the endpoint as a distributor only. This means that the endpoint does no actual work and only distributes the load among its enlisted workers. It cannot be combined with the Master and Worker profiles.
  • PerformanceCounters turns on the NServiceBus performance counters. Performance counters are enabled by default when running in Production profile.

Specifying which profiles to run

If the host is run without specifying a profile, NServiceBus defaults to the Production profile.

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 Integration and PerformanceCounters profiles:

.\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 Production and PerformanceCounters profiles:

.\NServiceBus.Host.exe /install nservicebus.production nservicebus.performancecounters

Logging

The built-in profiles use the following logging configurations:

ProfileAppenderThreshold
LiteConsoleDebug
IntegrationConsoleInfo
ProductionRolling FileConfigurable, Warn by default

The rolling file logs are written to the logfile in the same directory as the executable. The file grows to a maximum size of 1MB, then a new file is created. A maximum of 10 files is kept, then the oldest file is erased. If not specified otherwise, the logging threshold is set to the Warn level. To configure the logging threshold see changing logging level via config file.

For changes to the configuration to have an effect, the process must be restarted.

Refer to the Logging configuration article to learn about customizing logging configuration.

Persistence

In Versions 6 and above persistence has to be explicitly configured.

The built-in profiles use the following default persistence settings:

-LiteIntegrationProduction
TimeoutIn-MemoryRavenDB or as configuredRavenDB or as configured
SubscriptionIn-MemoryRavenDB or as configuredRavenDB or as configured
SagaIn-MemoryRavenDB or as configuredRavenDB or as configured
GatewayIn-MemoryRavenDB or as configuredRavenDB or as configured
Distributor---

In the Lite profile NServiceBus Host will always use the in-memory persistence. In the Integration and Production profiles, the Host verifies if a specific persistence mechanism is provided, e.g. in the endpoint configuration. If not specified otherwise, then RavenDB persistence will be used by default.


Last modified