In-Memory Persistence

Source
NuGet Package NServiceBus (7.2-pre)
This page targets a pre-release version and is subject to change prior to the final release.

Some scenarios require an in-memory persistence such as the development environment or a lightweight client not interested in durability across restarts:

7.x - 7.1 NServiceBus
endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Sagas>();
endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Subscriptions>();
endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Outbox>();
endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.GatewayDeduplication>();
All information stored in the In-Memory persistence is discarded when the process ends.
The Delayed Retries mechanism uses the timeout manager when a transport does not natively support delayed delivery. As Delayed Retries are enabled by default, using In-Memory persistence with a transport that uses the timeout manager has the risk of losing messages that have failed processing and are waiting for another retry attempt. Use In-Memory persistence only in scenarios where it is OK to lose messages.

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); // Present since 7.1.10

Last modified