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

      • 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

      • 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
      • withSnapshotSelectionCriteria

        EventSourcedBehavior<Command,​Event,​State> withSnapshotSelectionCriteria​(SnapshotSelectionCriteria selection)
        Deprecated.
        use withRecovery(Recovery.withSnapshotSelectionCriteria(...)). Since 2.6.5.
        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.

      • 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.

      • 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
      • eventAdapter

        EventSourcedBehavior<Command,​Event,​State> eventAdapter​(EventAdapter<Event,​?> adapter)
        Transform the event to 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.
      • snapshotAdapter

        EventSourcedBehavior<Command,​Event,​State> snapshotAdapter​(SnapshotAdapter<State> adapter)
        Transform the state to another type before giving to the journal. Can be used to transform older state types into the current state type e.g. when migrating from Persistent FSM to Typed EventSourcedBehavior.
      • 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.