AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/nservicebus/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

Error notifications

Component:
NServiceBus
NuGet Package:
NServiceBus 10.x

Error notifications are available for several events:

The following example shows how to be notified whenever a message is handled by recoverability. While this code writes to the console, any other action could be taken, for example, sending an email or writing to a monitoring system.

var recoverability = endpointConfiguration.Recoverability();

recoverability.Immediate(settings => settings.OnMessageBeingRetried((retry, ct) =>
{
    log.Info($"Message {retry.MessageId} will be retried immediately.");
    return Task.CompletedTask;
}));

recoverability.Delayed(settings => settings.OnMessageBeingRetried((retry, ct) =>
{
    log.Info($@"Message {retry.MessageId} will be retried after a delay.");
    return Task.CompletedTask;
}));

recoverability.Failed(settings => settings.OnMessageSentToErrorQueue((failed, ct) =>
{
    log.Fatal($@"Message {failed.MessageId} will be sent to the error queue.");
    return Task.CompletedTask;
}));

Message Body

Since the message could have failed due to a deserialization exception, it is not possible for the API to provide the instance of the message. For the same reason is it recommended that consumers of this API do not attempt to deserialize the message instance. If the message contents are required for debugging purposes, convert the message body to a string using the .NET Encoding APIs.

List of Samples