Getting Started
Architecture
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Modernization
Samples

Non-Durable Messaging

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

Relaxed message delivery guarantees to improve performance at the cost of reliability.

Overview

Non-durable messaging trades delivery guarantees for better performance, increasing the risk of message loss during server crashes or restarts.

Enabling non-durable messaging

This feature can be enabled in two ways

For specific message types

Via an Express attribute

A message can be configured to be non-durable via the use of an [ExpressAttribute].

[Express]
public class MessageWithExpress :
    IMessage
{
}

Using the configuration API

A subset of messages can be configured to be non-durable by using a convention.

var conventions = endpointConfiguration.Conventions();
conventions.DefiningExpressMessagesAs(
    type =>
    {
        return type.Name.EndsWith("Express");
    });

Global for the endpoint

Allows messages to be non-durable via the configuration API.

endpointConfiguration.DisableDurableMessages();

Effect on Transports

Each transport implements non-durable messaging differently based on its underlying technology.

MSMQ

MSMQ typically uses Store and Forward by default, storing messages durably on disk before delivery. With non-durable messaging, MSMQ sends messages in Express Mode by setting Message.Recoverable to false.

Non-durable messages require non-transactional queues. Configure this by setting useTransactionalQueues to false in the transport connection string.

RabbitMQ

Non-durable messages are sent using RabbitMQ's non-persistent delivery mode, which means the messages are not persisted to disk by the broker.

See controlling delivery mode in the RabbitMQ transport documentation.

SQL Server

The SQL Server transport has no support for this setting and it is ignored.

Azure Service Bus

The Azure Service Bus transport has no support for this setting and it is ignored.

Azure Storage Queues

The Azure Storage Queues transport has no support for this setting and it is ignored.

Amazon SQS

The Amazon SQS transport has no support for this setting and it is ignored.

Related Articles