Non-durable persistence

Standard support for version 7.x of NServiceBus has expired. For more information see our Support Policy.

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:

endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Sagas>();
endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Subscriptions>();
endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Outbox>();

Gateway deduplication

The in-memory gateway deduplication persistence uses an LRU cache. By default this cache can contain up to 10,000 items. The maximum size can be changed using the following API.

var persistence = endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.GatewayDeduplication>();
persistence.GatewayDeduplicationCacheSize(50000);

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.

By default, non-durable persistence uses optimistic concurrency control when updating or deleting saga data. If a conflict is detected a InvalidOperationException will be thrown describing the conflict.

Related Articles