Skip to content

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

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:

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.

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.