Redis journal storage
Orleans Journaling persists durable state changes as ordered journal data which is replayed to recover in-memory durable values and collections in DurableGrain grains. It’s a distinct mechanism from Event Sourcing, which uses JournaledGrain<TState, TEvent> and log-consistency providers.
The Microsoft.Orleans.Journaling.Redis package stores that journal data in Redis. Orleans Journaling is experimental and its APIs are marked with diagnostic ORLEANSEXP005.
Configure Redis journal storage
Section titled “Configure Redis journal storage”Configure the provider with AddRedisJournalStorage:
var builder = Host.CreateApplicationBuilder();builder.UseOrleans(siloBuilder =>{ siloBuilder.AddRedisJournalStorage(options => { options.ConfigurationOptions = new ConfigurationOptions { EndPoints = { "localhost:6379" }, AbortOnConnectFail = false }; });});
using var host = builder.Build();Storage behavior
Section titled “Storage behavior”The provider stores journal data in Redis strings and journal metadata in Redis hashes. Per-journal reads and mutations use atomic Lua scripts. Catalog operations discover journals by scanning metadata keys on each connected primary Redis server.
RedisJournalStorageOptions supports:
- ConfigurationOptions for the StackExchange.Redis connection.
- CreateMultiplexer to supply a shared or custom connection multiplexer.
- KeyPrefix to isolate journal keys. The default is
{ServiceId}/journaling. - GetKeyName to customize the journal key component.
- CompactionThresholdBytes to select when the provider requests compaction.
- ReadChunkSize to limit the size of recovery segments supplied to the journal consumer.
Changing the key prefix or key-name function doesn’t migrate existing journals. Retain the previous mapping or migrate the stored data before deploying the change.
Durability
Section titled “Durability”Redis journal durability depends on the Redis persistence and replication configuration. Configure persistence, such as append-only file (AOF) persistence with an appropriate appendfsync policy, according to the application’s recovery-point requirements.
Use a distinct KeyPrefix when multiple Orleans services share a Redis deployment.
