Getting Started
Architecture
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Non-Durable Messaging

Component: NServiceBus
NuGet Package: NServiceBus (7.x)

The use of non-durable messages involves relaxing message delivery guarantees in order to achieve better performance.

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

Individual transports interpret "non-durable" messaging with a custom approach dependent on how the underlying technology functions.

MSMQ

The default behavior of MSMQ is to use the concept of Store and Forward. In this approach, messages are stored durably on disk at the sender and then delivered by MSMQ to the receiver. When non-durable messaging is used, the MSMQ transport sends messages in Express Mode. The underlying setting that is used to achieve this is to set Message.Recoverable to false.

Non-durable messages require the queues to be non-transactional. Use non-transactional queues 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 have no support for this setting and it is ignored.

Azure Storage Queues

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

Amazon SQS

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

Related Articles