Recovering the state of an actor
Persistent actors recover the state based on their persistence ID. This ID needs to unique for a given persistent actor and within the data store. It is required to ensure the consistency of the journal when we persist events and when we recover. Each time a persistent actor is created, Akka persistence checks the journal and the snapshot stores for events and snapshots, respectively. The default behavior is to apply the latest snapshot and replay the missing events afterward. However, this behavior can be modified to our needs, as we will see in this recipe. In this recipe, we will show and explain what the different recovery strategies in Akka persistence are.
Getting ready
To step through this recipe, we need to import the hello-Akka
project in the IDE; other prerequisites are the same as earlier as we have downloaded the akka-persistence
dependency. For this recipe, we will use the LevelDB plugin.
How to do it…
For this recipe, we need to perform the following...