Understanding event sourcing
As we have been discussing through this whole chapter, event sourcing is the technique used by Akka persistence. Event sourcing is a pattern to store the state of entities where instead of persisting the actual state at a given time, you persist the changes happening to that particular entity. These changes are known as events. In this recipe, we will review the advantages of event sourcing and how this mechanism can be a better fit for distributed application.
Getting ready
There are no prerequisites for this recipe.
How to do it…
For this recipe, we will list the steps on how event sourcing works with Akka:
- Once we create a persistent actor, recovery triggers. Akka persistence checks whether there are either events in the journal or snapshots in the snapshot store for the given persistence ID.
- If it finds events in the journal, it proceeds to replay those events to update the state accordingly. If  your actor receives other messages while doing this, they get
stashed...