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.

Delayed Delivery

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

Messages don't need to be dispatched immediately. Delayed delivery is a feature that sends messages into the future to be delivered and processed at a later time.

Delayed delivery is used for:

Delay using a TimeSpan

Delays delivery of a message for a specified duration.

var sendOptions = new SendOptions();

sendOptions.DelayDeliveryWith(TimeSpan.FromMinutes(30));

await handlerContext.Send(new MessageToBeSentLater(), sendOptions);
// OR
await endpoint.Send(new MessageToBeSentLater(), sendOptions, handlerContext.CancellationToken);

Delay using a DateTime

Delays delivery of a message until a specified point in time.

var options = new SendOptions();
options.DoNotDeliverBefore(new DateTime(2016, 12, 25));

await handlerContext.Send(new MessageToBeSentLater(), options);
// OR
await endpoint.Send(new MessageToBeSentLater(), options, handlerContext.CancellationToken);

How it works

NServiceBus provides delayed delivery feature for transports that don't have native support for delayed message delivery. All Transports except MSMQ support delayed message delivery natively and therefore don't require persistence to store timeouts. To learn more about NServiceBus delayed message store refer to the MSMQ transport delayed delivery article.

List of Samples

  • Delayed Delivery
    A simple ordering system that defers handling or delivery of a message.