Configure error handling

Component: NServiceBus
Standard support for version 5.x of NServiceBus has expired. For more information see our Support Policy.

Configure the error queue address

When an endpoint fails to process a message successfully, NServiceBus automatically retries the message the configured number of times. If the message can not be processed successfully even after the retried attempts, NServiceBus forwards the message to a designated error queue.

When running with transport transactions disabled, NServiceBus will perform a best-effort error message forwarding, i.e. if moving to the error queue fails, the message will be lost.
When running with transport transactions disabled. Both immediate retries and delayed retries will be disabled automatically when transactions are turned off.

The error queue address is mandatory. It can be configured in several ways:

Configuring this feature via app.config, IConfigurationProvider, or IProvideConfiguration is deprecated in Version 7.

Using an IConfigurationProvider

class ProvideConfiguration :
    public MessageForwardingInCaseOfFaultConfig GetConfiguration()
        return new MessageForwardingInCaseOfFaultConfig
            ErrorQueue = "error"

Using an ConfigurationSource

public class ConfigurationSource :
    public T GetConfiguration<T>() where T : class, new()
        if (typeof(T) == typeof(MessageForwardingInCaseOfFaultConfig))
            var config = new MessageForwardingInCaseOfFaultConfig
                ErrorQueue = "error"

            return config as T;

        // Respect app.config for other sections not defined in this method
        return ConfigurationManager.GetSection(typeof(T).Name) as T;

Then at configuration time:

busConfiguration.CustomConfigurationSource(new ConfigurationSource());

Using App.Config

    <section name="MessageForwardingInCaseOfFaultConfig"
             type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
  <MessageForwardingInCaseOfFaultConfig ErrorQueue="error@adminMachine"/>

Error queue monitoring

Administrators should monitor the error queue in order to detect when problems occur. The message in the error queue contains relevant information such as the endpoint that originally processed the message and exception details. With this information, an administrator can investigate the problem and solve it, for example, bringing up a database that went down.

Monitoring and handling of failed messages with ServicePulse provides access to full exception details including the stack-trace. ServiceInsight offers advanced debugging capability providing additional information like exception details as well as visualizing the flow of messages. Both ServiceInsight and ServicePulse provide retry functionality that sends a failed message from the error queue back to the originating endpoint for re-processing. For more details on how to retry a message using ServicePulse, see Introduction to Failed Messages Monitoring in ServicePulse. To retry a message using ServiceInsight, see Managing Errors and Retries in ServiceInsight.

If either ServicePulse or ServiceInsight are not available in the environment, the retry operation can be performed using the native management tools appropriate for the selected transport:


Last modified