Interface EventSourcedBehavior<Command,Event,State>
-
public interface EventSourcedBehavior<Command,Event,State>
Further customization of theEventSourcedBehavior
can be done with the methods defined here.Not for user extension
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
EventSourcedBehavior.CommandHandler$
TheCommandHandler
defines how to act on commands.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description EventSourcedBehavior<Command,Event,State>
eventAdapter(EventAdapter<Event,?> adapter)
Transform the event to another type before giving to the journal.EventSourcedBehavior<Command,Event,State>
onPersistFailure(BackoffSupervisorStrategy backoffStrategy)
Back off strategy for persist failures.PersistenceId
persistenceId()
EventSourcedBehavior<Command,Event,State>
receiveSignal(scala.PartialFunction<scala.Tuple2<State,Signal>,scala.runtime.BoxedUnit> signalHandler)
Allows the event sourced behavior to react on signals.scala.PartialFunction<scala.Tuple2<State,Signal>,scala.runtime.BoxedUnit>
signalHandler()
EventSourcedBehavior<Command,Event,State>
snapshotAdapter(SnapshotAdapter<State> adapter)
Transform the state to another type before giving to the journal.EventSourcedBehavior<Command,Event,State>
snapshotWhen(scala.Function3<State,Event,java.lang.Object,java.lang.Object> predicate)
Initiates a snapshot if the givenpredicate
evaluates to true.EventSourcedBehavior<Command,Event,State>
withEventPublishing(boolean enabled)
Publish events to the system event stream asPublishedEvent
after they have been persistedEventSourcedBehavior<Command,Event,State>
withJournalPluginId(java.lang.String id)
Change the journal plugin id that this actor should use.EventSourcedBehavior<Command,Event,State>
withRecovery(Recovery recovery)
Change the recovery strategy.EventSourcedBehavior<Command,Event,State>
withReplication(akka.persistence.typed.internal.ReplicationContextImpl context)
INTERNAL APIEventSourcedBehavior<Command,Event,State>
withRetention(RetentionCriteria criteria)
Criteria for retention/deletion of snapshots and events.EventSourcedBehavior<Command,Event,State>
withSnapshotPluginId(java.lang.String id)
Change the snapshot store plugin id that this actor should use.EventSourcedBehavior<Command,Event,State>
withSnapshotSelectionCriteria(SnapshotSelectionCriteria selection)
Deprecated.use withRecovery(Recovery.withSnapshotSelectionCriteria(...)).EventSourcedBehavior<Command,Event,State>
withStashCapacity(int size)
Define a custom stash capacity per entity.EventSourcedBehavior<Command,Event,State>
withTagger(scala.Function1<Event,scala.collection.immutable.Set<java.lang.String>> tagger)
Thetagger
function should give event tags, which will be used in persistence query
-
-
-
Method Detail
-
persistenceId
PersistenceId persistenceId()
-
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
-
withJournalPluginId
EventSourcedBehavior<Command,Event,State> withJournalPluginId(java.lang.String id)
Change the journal plugin id that this actor should use.
-
withSnapshotPluginId
EventSourcedBehavior<Command,Event,State> withSnapshotPluginId(java.lang.String id)
Change the snapshot store plugin id that this actor should use.
-
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 givenpredicate
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 ifEventSourcedBehavior.withRetention
withRetentionCriteria.snapshotEvery
is used together withsnapshotWhen
. Such deletes are only triggered by snapshots matching thenumberOfEvents
in theRetentionCriteria
.
-
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.
-
withTagger
EventSourcedBehavior<Command,Event,State> withTagger(scala.Function1<Event,scala.collection.immutable.Set<java.lang.String>> tagger)
Thetagger
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 thanEvent
.
-
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.
This supervision is only around the event sourced behavior not any outer setup/withTimers block. If using restart, any actions e.g. scheduling timers, can be done on the PreRestart
If not specified the actor will be stopped on failure.
-
withRecovery
EventSourcedBehavior<Command,Event,State> withRecovery(Recovery recovery)
Change the recovery strategy. By default, snapshots and events are recovered.
-
withEventPublishing
EventSourcedBehavior<Command,Event,State> withEventPublishing(boolean enabled)
Publish events to the system event stream asPublishedEvent
after they have been persisted
-
withReplication
EventSourcedBehavior<Command,Event,State> withReplication(akka.persistence.typed.internal.ReplicationContextImpl context)
INTERNAL API
-
withStashCapacity
EventSourcedBehavior<Command,Event,State> withStashCapacity(int size)
Define a custom stash capacity per entity. If not defined, the defaultakka.persistence.typed.stash-capacity
will be used.
-
-