Interface EventSourcedBehavior<Command,​Event,​State>

  • All Known Implementing Classes:
    EventSourcedBehaviorImpl

    public interface EventSourcedBehavior<Command,​Event,​State>
    Further customization of the EventSourcedBehavior can be done with the methods defined here.

    Not for user extension

    • Method Detail

      • onRecoveryCompleted

        EventSourcedBehavior<Command,​Event,​State> onRecoveryCompleted​(scala.Function1<State,​scala.runtime.BoxedUnit> callback)
        The callback function is called to notify that the recovery process has finished.
        Parameters:
        callback - (undocumented)
        Returns:
        (undocumented)
      • onRecoveryFailure

        EventSourcedBehavior<Command,​Event,​State> onRecoveryFailure​(scala.Function1<java.lang.Throwable,​scala.runtime.BoxedUnit> callback)
        The callback function is called to notify that recovery has failed. For setting a supervision strategy onPersistFailure
        Parameters:
        callback - (undocumented)
        Returns:
        (undocumented)
      • onSnapshot

        EventSourcedBehavior<Command,​Event,​State> onSnapshot​(scala.Function2<SnapshotMetadata,​scala.util.Try<Done>,​scala.runtime.BoxedUnit> callback)
        The callback function is called to notify when a snapshot is complete.
        Parameters:
        callback - (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 function returns true. When persisting multiple events at once the snapshot is triggered after all the events have been persisted.

        predicate receives the State, Event and the sequenceNr used for the Event

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

        EventSourcedBehavior<Command,​Event,​State> snapshotEvery​(long numberOfEvents)
        Snapshot every N events

        numberOfEvents should be greater than 0

        Parameters:
        numberOfEvents - (undocumented)
        Returns:
        (undocumented)
      • 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)
      • 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)