akkadotnet / Akka.Persistence.Redis

Redis storage for Akka.NET Persistence

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to Use Multiple Named Redis journal/snapshot-store Configurations

RobinJDCox opened this issue · comments

The obvious example of this would be if you want to have your sharding persistence in a different key-space (or database) to the rest of your Journal/Snapshot persistence.

On reading the following from this blog about getting sharding working I started trying to separate my sharding persistence from my main business logic.

Akka.Cluster.Sharding will use the default event journal and snapshot plugin if not told to do otherwise. This means, that you may end with your business and sharding event mixed up with each other inside the same collections/tables. While it’s not mandatory, it’s good to configure cluster sharding to operate on a separate collections.

When running with Sql Server for my persistence, the example configuration from the blog I mentioned work fine. So I tried a similar pattern with this Redis but it seemed to be just using the default config (specifically using the same key-space).

Below is an example of the configuration I tried.

cluster.sharding {
    journal-plugin-id = "akka.persistence.journal.sharding"
    snapshot-plugin-id = "akka.persistence.snapshot-store.sharding"
}
persistence {
    journal {
        plugin = "akka.persistence.journal.redis"
        redis {
            class = "Akka.Persistence.Redis.Journal.RedisJournal, Akka.Persistence.Redis"
            configuration-string = "example"
            plugin-dispatcher = "akka.actor.default-dispatcher"
            key-prefix = "akka:persistence:journal"
        }
        sharding {
            class = "Akka.Persistence.Redis.Journal.RedisJournal, Akka.Persistence.Redis"
            configuration-string = "example"
            plugin-dispatcher = "akka.actor.default-dispatcher"
            key-prefix = "akka:persistence:sharding:journal"
        }
    }
    snapshot-store {
        plugin = "akka.persistence.snapshot-store.redis"
        redis {
            class = "Akka.Persistence.Redis.Journal.RedisJournal, Akka.Persistence.Redis"
            configuration-string = "example"
            plugin-dispatcher = "akka.actor.default-dispatcher"
            key-prefix = "akka:persistence:snapshot"
        }                    
        sharding {
            class = "Akka.Persistence.Redis.Snapshot.RedisSnapshotStore, Akka.Persistence.Redis"
            configuration-string = "example"
            plugin-dispatcher = "akka.actor.default-dispatcher"
            key-prefix = "akka:persistence:sharding:snapshot"
        }
    }
}

What I was hoping I'd be able to do is have my systems journal and snapshot data to be stored using key prefixes of akka.persistence.journal and akka.persistence.snapshot respectively and my sharding data to be using akka.persistence.sharding.journal and akka.persistence.sharding.snapshot
Instead both the data from my system and all the sharding data is stored using these two key-prefixes - akka.persistence.journal and akka.persistence.snapshot

Can we get this updated so that this is configurable in the same way as the Akka.Persistence.SqlServer package?

any update on this issue?

Hi!
Is it fixed or not?
Faced with the same issue using cluster sharding with redis plugin

@maxkornev whoops, we got Redis Sharding to work but I don't know about this. I don't think Akka.Persistence itself can support having multiple concurrent journal configs like this so I believe this is a won't-fix.

Enable DData for sharding if you want to offload sharding data from Akka.Persistence.

Whoops, didn't meant to close this again.

cc @Arkatufus can you investigate? I believe the blog post is wrong - not persistence.

The blog should be correct, we do have a HOCON setting to enable this.