

It is difficult to safely fail over the persistent actor from one data center to the other because: This restriction means that the single persistent actor can only live in one data center and would not be available during network partitions between the data centers. Otherwise, multiple instances would store interleaving events based on different states, and when these events would later be replayed it would not be possible to reconstruct the correct state. Serve requests from a location near the user to provide better responsiveness.Īkka Persistence is using event sourcing that is based on the single writer principle, which means that there can only be one active instance of a PersistentActor with a given persistenceId.Redundancy to tolerate failures in one location and still be operational.There can be many reasons for using more than one data center, such as: It is a short and recommended read if you’re starting developing Events based applications. More details and examples can be found in the Akka documentation.Īnother excellent article about “thinking in Events” is Events As First-Class Citizens by Randy Shoup. The behavior of a PersistentActor an AbstractPersistentActor is defined by implementing receiveRecover createReceiveRecover and receiveCommand createReceive. An actor that extends this trait class uses the persist method to persist and handle events.

This design of capturing all changes as domain events, which are immutable facts of things that have happened, is known as event sourcingĪkka persistence supports event sourcing with the PersistentActor trait AbstractPersistentActor abstract class. Such stateful actors are recovered by replaying stored changes to these actors from which they can rebuild internal state. The key concept behind Akka persistence is that only changes to an actor’s internal state are persisted but never its current state directly (except for optional snapshots). The reference documentation describes all details of Akka Persistence but here is a short summary in case you are not familiar with the concepts.Īkka persistence enables stateful actors to persist their internal state so that it can be recovered when an actor is started, restarted after a JVM crash or by a supervisor, or migrated in a cluster. This feature is included in a subscription to Lightbend Platform, which includes other technology enhancements, monitoring and telemetry, and one-to-one support from the expert engineers behind Akka.
