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:

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);

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

In-memory persistence uses optimistic concurrency control when updating or deleting saga data.

Example exception:

System.Exception: InMemorySagaPersister concurrency violation: saga entity Id[a15a31fd-4f25-4dc3-b556-aad200e52dcb] already saved.

Last modified