Class AbstractPersistentActor

java.lang.Object
org.apache.pekko.actor.AbstractActor
org.apache.pekko.persistence.AbstractPersistentActor
All Implemented Interfaces:
Actor, Stash, StashFactory, StashSupport, UnrestrictedStash, RequiresMessageQueue<DequeBasedMessageQueueSemantics>, AbstractPersistentActorLike, Eventsourced, PersistenceIdentity, PersistenceRecovery, PersistenceStash, Snapshotter
Direct Known Subclasses:
AbstractPersistentActorWithAtLeastOnceDelivery

public abstract class AbstractPersistentActor extends AbstractActor implements AbstractPersistentActorLike
Java API: an persistent actor - can be used to implement command or Event Sourcing.
  • Constructor Details

    • AbstractPersistentActor

      public AbstractPersistentActor()
  • Method Details

    • createReceive

      public abstract AbstractActor.Receive createReceive()
      An persistent actor has to define its initial receive behavior by implementing the createReceive method, also known as the command handler. Typically validates commands against current state (and/or by communication with other actors). On successful validation, one or more events are derived from a command and these events are then persisted by calling persist.
      Specified by:
      createReceive in interface AbstractPersistentActorLike
      Specified by:
      createReceive in class AbstractActor
    • createReceiveRecover

      public abstract AbstractActor.Receive createReceiveRecover()
      Recovery handler that receives persisted events during recovery. If a state snapshot has been captured and saved, this handler will receive a SnapshotOffer message followed by events that are younger than the offered snapshot.

      This handler must not have side-effects other than changing persistent actor state i.e. it should not perform actions that may fail, such as interacting with external services, for example.

      If there is a problem with recovering the state of the actor from the journal, the error will be logged and the actor will be stopped.

      Specified by:
      createReceiveRecover in interface AbstractPersistentActorLike
      See Also:
    • journal

      protected ActorRef journal()
      Specified by:
      journal in interface Eventsourced
    • org$apache$pekko$actor$StashSupport$_setter_$mailbox_$eq

      protected void org$apache$pekko$actor$StashSupport$_setter_$mailbox_$eq(DequeBasedMessageQueueSemantics x$1)
      Specified by:
      org$apache$pekko$actor$StashSupport$_setter_$mailbox_$eq in interface StashSupport
    • snapshotStore

      protected ActorRef snapshotStore()
      Description copied from interface: Snapshotter
      Snapshot store plugin actor.
      Specified by:
      snapshotStore in interface Eventsourced
      Specified by:
      snapshotStore in interface Snapshotter