In-Memory Persistence

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

5.x NServiceBus
var persistence = busConfiguration.UsePersistence<InMemoryPersistence>();
persistence.For(
    Storage.Sagas,
    Storage.Subscriptions,
    Storage.Timeouts,
    Storage.Outbox,
    Storage.GatewayDeduplication);
5.2 NServiceBus
busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Sagas>();
busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Subscriptions>();
busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Outbox>();
busConfiguration.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.

Last modified