Interface EventSourcedBehavior<Command,​Event,​State>

  • All Known Implementing Classes:
    EventSourcedBehaviorImpl

    public interface EventSourcedBehavior<Command,​Event,​State>
    Allows the event sourced behavior to react on signals.

    The regular lifecycle signals can be handled as well as Akka Persistence specific signals (snapshot and recovery related). Those are all subtypes of EventSourcedSignal

    • Method Detail

      • receiveSignal

        EventSourcedBehavior<Command,​Event,​State> receiveSignal​(scala.PartialFunction<scala.Tuple2<State,​Signal>,​scala.runtime.BoxedUnit> signalHandler)
        Allows the event sourced behavior to react on signals.

        The regular lifecycle signals can be handled as well as Akka Persistence specific signals (snapshot and recovery related). Those are all subtypes of EventSourcedSignal

        Parameters:
        signalHandler - (undocumented)
        Returns:
        (undocumented)
      • signalHandler

        scala.PartialFunction<scala.Tuple2<State,​Signal>,​scala.runtime.BoxedUnit> signalHandler()
        Returns:
        The currently defined signal handler or an empty handler if no custom handler previously defined
      • withJournalPluginId

        EventSourcedBehavior<Command,​Event,​State> withJournalPluginId​(java.lang.String id)
        Change the journal plugin id that this actor should use.
        Parameters:
        id - (undocumented)
        Returns:
        (undocumented)
      • withSnapshotPluginId

        EventSourcedBehavior<Command,​Event,​State> withSnapshotPluginId​(java.lang.String id)
        Change the snapshot store plugin id that this actor should use.
        Parameters:
        id - (undocumented)
        Returns:
        (undocumented)
      • withSnapshotSelectionCriteria

        EventSourcedBehavior<Command,​Event,​State> withSnapshotSelectionCriteria​(SnapshotSelectionCriteria selection)
        Changes the snapshot selection criteria used by this behavior. By default the most recent snapshot is used, and the remaining state updates are recovered by replaying events from the sequence number up until which the snapshot reached.

        You may configure the behavior to skip replaying snapshots completely, in which case the recovery will be performed by replaying all events -- which may take a long time.

        Parameters:
        selection - (undocumented)
        Returns:
        (undocumented)
      • snapshotWhen

        EventSourcedBehavior<Command,​Event,​State> snapshotWhen​(scala.Function3<State,​Event,​java.lang.Object,​java.lang.Object> predicate)
        Initiates a snapshot if the given predicate evaluates to true.

        Decide to store a snapshot based on the State, Event and sequenceNr when the event has been successfully persisted.

        When persisting multiple events at once the snapshot is triggered after all the events have been persisted.

        Snapshots triggered by snapshotWhen will not trigger deletes of old snapshots and events if EventSourcedBehavior.withRetention with RetentionCriteria.snapshotEvery is used together with snapshotWhen. Such deletes are only triggered by snapshots matching the numberOfEvents in the RetentionCriteria.

        Parameters:
        predicate - (undocumented)
        Returns:
        (undocumented)
      • withRetention

        EventSourcedBehavior<Command,​Event,​State> withRetention​(RetentionCriteria criteria)
        Criteria for retention/deletion of snapshots and events. By default, retention is disabled and snapshots are not saved and deleted automatically.
        Parameters:
        criteria - (undocumented)
        Returns:
        (undocumented)
      • withTagger

        EventSourcedBehavior<Command,​Event,​State> withTagger​(scala.Function1<Event,​scala.collection.immutable.Set<java.lang.String>> tagger)
        The tagger function should give event tags, which will be used in persistence query
        Parameters:
        tagger - (undocumented)
        Returns:
        (undocumented)
      • eventAdapter

        EventSourcedBehavior<Command,​Event,​State> eventAdapter​(EventAdapter<Event,​?> adapter)
        Transform the event in another type before giving to the journal. Can be used to wrap events in types Journals understand but is of a different type than Event.
        Parameters:
        adapter - (undocumented)
        Returns:
        (undocumented)
      • onPersistFailure

        EventSourcedBehavior<Command,​Event,​State> onPersistFailure​(BackoffSupervisorStrategy backoffStrategy)
        Back off strategy for persist failures.

        Specifically BackOff to prevent resume being used. Resume is not allowed as it will be unknown if the event has been persisted.

        If not specified the actor will be stopped on failure.

        Parameters:
        backoffStrategy - (undocumented)
        Returns:
        (undocumented)