Non-durable persistence

NuGet Package:
NServiceBus.Persistence.NonDurable 2.x
Target Version:
NServiceBus 9.x

Some scenarios require a non-durable persistence such as the development environment, testing, high-throughput scenarios where speed outweighs the benefits of durability, or a lightweight client not interested in durability across restarts:

Persistence at a glance

For a description of each feature, see the persistence at a glance legend.

Feature
Storage TypesSagas, Outbox, Subscriptions
TransactionsSynchronized storage session
Concurrency controlOptimistic concurrency
Scripted deploymentDoes not apply
InstallersDoes not apply

Configuration

Configure the endpoint to use non-durable persistence:

// Use NonDurable persistence for all concerns
endpointConfiguration.UsePersistence<NonDurablePersistence>();

// or select specific concerns
endpointConfiguration.UsePersistence<NonDurablePersistence, StorageType.Sagas>();
endpointConfiguration.UsePersistence<NonDurablePersistence, StorageType.Subscriptions>();
endpointConfiguration.UsePersistence<NonDurablePersistence, StorageType.Outbox>();

Saga concurrency

When simultaneously handling messages, conflicts may occur. See below for examples of the exceptions which are thrown. Saga concurrency explains how these conflicts are handled, and contains guidance for high-load scenarios.

Starting a saga

Example exception:

System.InvalidOperationException: The saga with the correlation id 'Name: OrderId Value: f05c6e0c-aea6-48d6-846c-d1663998ebf2' already exists

Updating or deleting saga data

Non-durable persistence uses optimistic concurrency control when updating or deleting saga data.

Example exception:

System.InvalidOperationException: Saga with Id '7ac53d15-4742-4e38-9e2f-6d75c25b6621' can't be updated because it was updated by another process.

Related Articles