How to access akka persistence recovery from lagom PersistentEntity?


(Bozo Dragojevic) #1

I’d like to reconstruct the state() of a PersistentEntity up to a point in the event stream.

Is there an elegant way of doing that?


(Renato) #2

You can’t do it out of the box. This is actually something that should be done on the read-side. Usually, the state of an entity should only be used to validate the next command.

Do you need to do it ad-hoc? Otherwise, I would suggest a read-side processor where you create different views that are build up to a given point in time.

If you really need to do it ad-hoc, you can go one level deeper and use akka-persistence-query API directly. You can ask for the events for a given PersistentActor ID. You will get a Source[Event] that you can consume. You can then use the same event handlers you defined for you PersistentEntity.