public interface PersistentFSM<S extends PersistentFSM.FSMState,D,E> extends PersistentActor, PersistentFSMBase<S,D,E>, ActorLogging
Supports the usual FSM
functionality with additional persistence features.
PersistentFSM
is identified by 'persistenceId' value.
State changes are persisted atomically together with domain events, which means that either both succeed or both fail,
i.e. a state transition event will not be stored if persistence of an event related to that change fails.
Persistence execution order is: persist -> wait for ack -> apply state.
Incoming messages are deferred until the state is applied.
State Data is constructed based on domain events, according to user's implementation of applyEvent function.
This is an EXPERIMENTAL feature and is subject to change until it has received more real world testing.
Modifier and Type | Interface and Description |
---|---|
static class |
PersistentFSM.$minus$greater$
This extractor is just convenience for matching a (S, S) pair, including a
reminder what the new state is.
|
static class |
PersistentFSM.CurrentState<S>
Message type which is sent directly to the subscribed actor in
FSM.SubscribeTransitionCallBack before sending any
FSM.Transition messages. |
static class |
PersistentFSM.CurrentState$ |
static class |
PersistentFSM.Event<D>
All messages sent to the
FSM will be wrapped inside an
Event , which allows pattern matching to extract both state and data. |
static class |
PersistentFSM.Event$ |
static class |
PersistentFSM.Failure
Signifies that the
FSM is shutting itself down because of
an error, e.g. |
static class |
PersistentFSM.Failure$ |
static interface |
PersistentFSM.FSMState
FSMState base trait, makes possible for simple default serialization by conversion to String
|
static class |
PersistentFSM.LogEntry<S,D>
Log Entry of the
LoggingFSM , can be obtained by calling getLog . |
static class |
PersistentFSM.LogEntry$ |
static class |
PersistentFSM.Normal$
Default reason if calling
stop() . |
static class |
PersistentFSM.NullFunction$
A partial function value which does not match anything and can be used to
“reset”
whenUnhandled and onTermination handlers. |
static interface |
PersistentFSM.PersistentFsmEvent
Base persistent event class
|
static class |
PersistentFSM.PersistentFSMSnapshot<D>
FSM state and data snapshot
|
static class |
PersistentFSM.PersistentFSMSnapshot$ |
static interface |
PersistentFSM.Reason
Reason why this
FSM is shutting down. |
static class |
PersistentFSM.Shutdown$
Reason given when someone was calling
system.stop(fsm) from outside;
also applies to Stop supervision directive. |
static class |
PersistentFSM.State<S,D,E>
This captures all of the managed state of the
FSM : the state
name, the state data, possibly custom timeout, stop reason, replies
accumulated while processing the last message, possibly domain event and handler
to be executed after FSM moves to the new state (also triggered when staying in the same state) |
static class |
PersistentFSM.State$ |
static class |
PersistentFSM.StateChangeEvent
Persisted on state change
|
static class |
PersistentFSM.StateChangeEvent$ |
static class |
PersistentFSM.StateTimeout$
This case object is received in case of a state timeout.
|
static class |
PersistentFSM.StopEvent<S,D>
Case class representing the state of the
FSM whithin the
onTermination block. |
static class |
PersistentFSM.StopEvent$ |
static class |
PersistentFSM.SubscribeTransitionCallBack
Send this to an
FSM to request first the PersistentFSM.CurrentState
and then a series of PersistentFSM.Transition updates. |
static class |
PersistentFSM.SubscribeTransitionCallBack$ |
static class |
PersistentFSM.TimeoutMarker
INTERNAL API
|
static class |
PersistentFSM.TimeoutMarker$ |
static class |
PersistentFSM.Timer
INTERNAL API
|
static class |
PersistentFSM.Timer$ |
static class |
PersistentFSM.Transition<S>
Message type which is used to communicate transitions between states to
all subscribed listeners (use
FSM.SubscribeTransitionCallBack ). |
static class |
PersistentFSM.Transition$ |
static class |
PersistentFSM.UnsubscribeTransitionCallBack
Unsubscribe from
FSM.Transition notifications which was
effected by sending the corresponding FSM.SubscribeTransitionCallBack . |
static class |
PersistentFSM.UnsubscribeTransitionCallBack$ |
Eventsourced.AsyncHandlerInvocation, Eventsourced.AsyncHandlerInvocation$, Eventsourced.PendingHandlerInvocation, Eventsourced.RecoveryTick, Eventsourced.RecoveryTick$, Eventsourced.StashingHandlerInvocation, Eventsourced.StashingHandlerInvocation$
Actor.emptyBehavior$, Actor.ignoringBehavior$
PersistentFSMBase.TransformHelper
Modifier and Type | Method and Description |
---|---|
D |
applyEvent(E domainEvent,
D currentData)
Override this handler to define the action on Domain Event
|
void |
applyState(PersistentFSM.State<S,D,E> nextState)
Persist FSM State and FSM State Data
|
scala.reflect.ClassTag<E> |
domainEventClassTag()
Enables to pass a ClassTag of a domain event base type from the implementing class
|
scala.reflect.ClassTag<E> |
domainEventTag()
Domain event's
ClassTag
Used for identifying domain events during recovery |
void |
onRecoveryCompleted()
Override this handler to define the action on recovery completion
|
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
receiveCommand()
After recovery events are handled as in usual FSM actor
|
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
receiveRecover()
Discover the latest recorded state
|
void |
saveStateSnapshot()
Save the current state as a snapshot
|
scala.collection.immutable.Map<java.lang.String,S> |
statesMap()
Map from state identifier to state instance
|
receive
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, changeState, deferAsync, deleteMessages, flushBatch, flushJournalBatch, journal, lastSequenceNr, log, nextSequenceNr, onPersistFailure, onPersistRejected, onRecoveryFailure, onReplaySuccess, peekApplyHandler, persist, persist, persistAll, persistAllAsync, persistAsync, persistAsync, recovering, recoveryFinished, recoveryRunning, recoveryStarted, requestRecoveryPermit, setLastSequenceNr, snapshotSequenceNr, snapshotStore, snapshotterId, startRecovery, stashInternally, unhandled, unstashAll, unstashInternally, updateLastSequenceNr, waitingRecoveryPermit
deleteSnapshot, deleteSnapshots, loadSnapshot, saveSnapshot
internalStashOverflowStrategy
context, postRestart, preStart, self, sender, supervisorStrategy
actorCell, clearStash, context, enqueueFirst, mailbox, prepend, self, stash, unstash, unstashAll
createStash
journalPluginId, persistenceId, snapshotPluginId
recovery
cancelTimer, debugEvent, Event, handleTransition, initialize, isStateTimerActive, isTimerActive, logTermination, makeTransition, nextStateData, onTermination, onTransition, postStop, processEvent, processMsg, receive, register, setStateTimeout, setTimer, startWith, stateData, stateName, stateNames, StateTimeout, stay, stop, stop, stop, StopEvent, terminate, total2pf, transform, when, whenUnhandled
gossip, listenerManagement, listeners
log
scala.reflect.ClassTag<E> domainEventClassTag()
ClassTag
of domain event base typescala.reflect.ClassTag<E> domainEventTag()
ClassTag
Used for identifying domain events during recoveryscala.collection.immutable.Map<java.lang.String,S> statesMap()
D applyEvent(E domainEvent, D currentData)
domainEvent
- domain event to applycurrentData
- state data of the previous statevoid onRecoveryCompleted()
void saveStateSnapshot()
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveCommand()
receiveCommand
in interface Eventsourced
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveRecover()
receiveRecover
in interface Eventsourced
Recovery
void applyState(PersistentFSM.State<S,D,E> nextState)
applyState
in interface PersistentFSMBase<S extends PersistentFSM.FSMState,D,E>
nextState
- (undocumented)