Read journal for replaying persistent messages

I am a Lagom user looking to offload the EventsByPersistenceIdQuery to a read-only replica database. From what I can tell, the Persistent actor is using the write journal’s messsages query to retrieve events by persistence id. Is it possible to configure akka-persistence to use the read-journal instead?

1 Like

I’m not quite sure from within the context of Lagom but if you use the Akka APIs directly you can configure a separate named journal config that points to the replica and use that for the query. You would then use that separate name when accessing the read journal like in the sample in the docs:

I’m more interested in learning about why AsyncRecovery uses the asyncReplayMessages, which uses the write journal’s messages query instead of the read journal’s messages query. If possible, I’d like to configure AsyncRecovery to use the read journal instead, but I’m interested to see if that is an advised pattern or not.

Recovery uses the write journal because it is a part of Akka Persistence and what a journal must support to be able to persist and recover the state of an actor. Read journals are in a separate module, Akka Persistence Query, and a given journal implementation could implement only the persistent actor journal side of things (even if most journals do implement both).