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 default error queue name is error
but some transports require it to be explicitly configured.
Using code
endpointConfiguration.SendFailedMessagesTo("targetErrorQueue");
Configuring this feature via app.
, IConfigurationProvider
, or IProvideConfiguration
is deprecated in Version 7.
Error message header customizations
Before a message is moved to the error queue, it is possible to inspect and modify the error forwarding headers.
Before Version 8, modifying existing headers on the failed message was possible. Starting in Version 8, use a recoverability pipeline behavior to get full access to all headers. See the upgrade guide for more information.
The following snippet shows how to configure header customizations and perform header value modification.
var recoverability = endpointConfiguration.Recoverability();
recoverability.Failed(
failed =>
{
failed.HeaderCustomization(headers =>
{
if (headers.ContainsKey("NServiceBus.ExceptionInfo.Message"))
{
headers["NServiceBus.ExceptionInfo.Message"] = "message override";
}
});
});
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 initially processed the message and exception details. This allows an administrator to investigate the problem.
Monitoring and handling of failed messages with ServicePulse provides access to full exception details, including the stack-trace. ServiceInsight provides advanced debugging capabilities by offering additional information, such as message flow visualization. Both ServiceInsight and ServicePulse provide message retry functionality, which sends a failed message back to the originating endpoint for reprocessing. 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 ServicePulse and ServiceInsight are not available in the environment, the message retry functionality can be performed using the native management tools appropriate for the selected transport: