Akka offers two types of persistence: Durable State and Event Sourcing. In case of a failure or restart, will the actor’s state be restored in both cases or only when using Event Sourcing?
In my application, I used Durable State and PostgreSQL to store the actor’s state, but when I restart my pod, the actor’s state is not being restored. Can anyone help me with this issue?
Note that the actor state is only restored when an actor with the same persistence id is started, normally you use persistent actors together with sharding using the persistence id as a logical “entity id” of your entities, that way a persisted actor will be woken up and reach it’s previous state whenever a message to that id is sent. You can see an example of this here: Section 4: Create the Event Sourced Cart entity :: Akka Guide
If you do not want to use sharding, remembering what persistence ids to start on application start and making sure only one instance of the same persistence id is running at the same time will be something you need implement in your own application logic.