Interface Eventsourced
-
- All Superinterfaces:
Actor,PersistenceIdentity,PersistenceRecovery,PersistenceStash,RequiresMessageQueue<DequeBasedMessageQueueSemantics>,Snapshotter,Stash,StashFactory,StashSupport,UnrestrictedStash
- All Known Subinterfaces:
AbstractPersistentActorLike,AtLeastOnceDelivery,AtLeastOnceDeliveryLike,PersistentActor
- All Known Implementing Classes:
AbstractPersistentActor,AbstractPersistentActorWithAtLeastOnceDelivery,AbstractPersistentActorWithTimers,JournalPerfSpec.BenchActor,PersistentShardCoordinator
public interface Eventsourced extends Snapshotter, PersistenceStash, PersistenceIdentity, PersistenceRecovery
INTERNAL API.Scala API and implementation details of
PersistentActorandAbstractPersistentActor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classEventsourced.AsyncHandlerInvocationINTERNAL API: does not force the actor to stash commands; Originates from either `persistAsync` or `defer` callsstatic classEventsourced.AsyncHandlerInvocation$static interfaceEventsourced.PendingHandlerInvocationINTERNAL APIstatic classEventsourced.RecoveryTickINTERNAL API: message used to detect that recovery timed outstatic classEventsourced.RecoveryTick$static classEventsourced.StashingHandlerInvocationINTERNAL API: forces actor to stash incoming commands until all these invocations are handledstatic classEventsourced.StashingHandlerInvocation$static interfaceEventsourced.State-
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void_lastSequenceNr_$eq(long x$1)voidaroundPostRestart(java.lang.Throwable reason)INTERNAL API.voidaroundPostStop()INTERNAL API.voidaroundPreRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message)INTERNAL API.voidaroundPreStart()INTERNAL API.voidaroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, java.lang.Object message)INTERNAL API.voidbatchAtomicWrite(AtomicWrite atomicWrite)voidchangeState(Eventsourced.State state)java.lang.ObjectcurrentCommand()voidcurrentState_$eq(Eventsourced.State x$1)voiddeleteMessages(long toSequenceNr)Permanently deletes all persistent messages with sequence numbers less than or equaltoSequenceNr.voideventBatch_$eq(scala.collection.immutable.List<PersistentEnvelope> x$1)voidflushBatch()voidflushJournalBatch()java.lang.ObjectgetAndClearInstrumentationContext(long seqNr)voidinstrumentationContexts_$eq(scala.collection.immutable.Map<java.lang.Object,java.lang.Object> x$1)<A> voidinternalDefer(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal API<A> voidinternalDeferAsync(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal APIvoidinternalDeleteMessagesBeforeSnapshot(SaveSnapshotSuccess e, int keepNrOfBatches, int snapshotAfter)INTERNAL API.<A> voidinternalPersist(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal API<A> voidinternalPersistAll(scala.collection.immutable.Seq<A> events, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal API<A> voidinternalPersistAllAsync(scala.collection.immutable.Seq<A> events, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal API<A> voidinternalPersistAsync(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal APIActorRefjournal()voidjournalBatch_$eq(scala.collection.immutable.Vector<PersistentEnvelope> x$1)longlastSequenceNr()Highest received sequence number so far or0Lif this actor hasn't replayed or stored any persistent events yet.LoggingAdapterlog()longnextSequenceNr()voidonPersistFailure(java.lang.Throwable cause, java.lang.Object event, long seqNr)Called when persist fails.voidonPersistRejected(java.lang.Throwable cause, java.lang.Object event, long seqNr)Called when the journal rejectedpersistof an event.voidonRecoveryFailure(java.lang.Throwable cause, scala.Option<java.lang.Object> event)Called whenever a message replay fails.voidonRecoveryFailureAndInstrumentation(java.lang.Throwable cause, scala.Option<java.lang.Object> event)voidonReplaySuccess()INTERNAL API.voidpeekApplyHandler(java.lang.Object payload)voidpendingStashingPersistInvocations_$eq(long x$1)scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>receiveCommand()Command handler.scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>receiveRecover()Recovery handler that receives persisted events during recovery.java.lang.Objectrecovering(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> recoveryBehavior, scala.concurrent.duration.FiniteDuration timeout)booleanrecoveryFinished()Returnstrueif this persistent actor has successfully finished recovery.booleanrecoveryRunning()Returnstrueif this persistent actor is currently recovering.java.lang.ObjectrecoveryStarted(long replayMax, scala.concurrent.duration.FiniteDuration timeout)voidrequestRecoveryPermit()voidsendBatchedEventsToJournal(scala.collection.immutable.Vector<PersistentEnvelope> journalBatch)voidsequenceNr_$eq(long x$1)voidsetLastSequenceNr(long value)longsnapshotSequenceNr()ReturnslastSequenceNr.ActorRefsnapshotStore()Snapshot store plugin actor.java.lang.StringsnapshotterId()ReturnspersistenceId.voidstartRecovery(Recovery recovery)voidstash()Adds the current message (the message that the actor received last) to the actor's stash.voidstashInternally(java.lang.Object currMsg)voidsuper$aroundPostRestart(java.lang.Throwable reason)INTERNAL API.voidsuper$aroundPostStop()INTERNAL API.voidsuper$aroundPreRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message)INTERNAL API.voidsuper$aroundPreStart()voidsuper$aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, java.lang.Object msg)Processes a loaded snapshot, if any.voidsuper$stash()Returnstrueif this persistent actor has successfully finished recovery.voidsuper$unhandled(java.lang.Object message)voidunhandled(java.lang.Object message)User overridable callback.voidunstashAll()Prepends all messages in the stash to the mailbox, and then clears the stash.voidunstashInternally(boolean all)voidupdateLastSequenceNr(PersistentRepr persistent)java.lang.ObjectwaitingRecoveryPermit(Recovery recovery)voidwriteEventFailed(PersistentRepr p, java.lang.Throwable cause)voidwriteEventRejected(PersistentRepr p, java.lang.Throwable cause)voidwriteEventSucceeded(PersistentRepr p)voidwriteInProgress_$eq(boolean x$1)-
Methods inherited from interface akka.actor.Actor
akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, context, postRestart, preStart, receive, self, sender, supervisorStrategy
-
Methods inherited from interface akka.persistence.PersistenceIdentity
journalPluginId, persistenceId, snapshotPluginId
-
Methods inherited from interface akka.persistence.PersistenceRecovery
recovery
-
Methods inherited from interface akka.persistence.PersistenceStash
internalStashOverflowStrategy
-
Methods inherited from interface akka.persistence.Snapshotter
deleteSnapshot, deleteSnapshots, loadSnapshot, saveSnapshot
-
Methods inherited from interface akka.actor.StashFactory
createStash
-
Methods inherited from interface akka.actor.StashSupport
actorCell, akka$actor$StashSupport$_setter_$mailbox_$eq, clearStash, context, enqueueFirst, mailbox, prepend, self, theStash_$eq, unstash, unstashAll
-
Methods inherited from interface akka.actor.UnrestrictedStash
postStop, preRestart, super$postStop, super$preRestart
-
-
-
-
Method Detail
-
super$aroundPreStart
void super$aroundPreStart()
-
super$aroundPreRestart
void super$aroundPreRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message)INTERNAL API.
-
super$aroundPostRestart
void super$aroundPostRestart(java.lang.Throwable reason)
INTERNAL API.
-
super$aroundPostStop
void super$aroundPostStop()
INTERNAL API.
-
super$unhandled
void super$unhandled(java.lang.Object message)
-
super$stash
void super$stash()
Returnstrueif this persistent actor has successfully finished recovery.
-
super$aroundReceive
void super$aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, java.lang.Object msg)Processes a loaded snapshot, if any. A loaded snapshot is offered with aSnapshotOffermessage to the actor'sreceiveRecover. Then initiates a message replay, either starting from the loaded snapshot or from scratch, and switches torecoveryStartedstate. All incoming messages are stashed.- Parameters:
replayMax- maximum number of messages to replay.timeout- recovery event timeout
-
journal
ActorRef journal()
-
snapshotStore
ActorRef snapshotStore()
Description copied from interface:SnapshotterSnapshot store plugin actor.- Specified by:
snapshotStorein interfaceSnapshotter
-
journalBatch_$eq
void journalBatch_$eq(scala.collection.immutable.Vector<PersistentEnvelope> x$1)
-
writeInProgress_$eq
void writeInProgress_$eq(boolean x$1)
-
sequenceNr_$eq
void sequenceNr_$eq(long x$1)
-
_lastSequenceNr_$eq
void _lastSequenceNr_$eq(long x$1)
-
currentState_$eq
void currentState_$eq(Eventsourced.State x$1)
-
pendingStashingPersistInvocations_$eq
void pendingStashingPersistInvocations_$eq(long x$1)
-
eventBatch_$eq
void eventBatch_$eq(scala.collection.immutable.List<PersistentEnvelope> x$1)
-
instrumentationContexts_$eq
void instrumentationContexts_$eq(scala.collection.immutable.Map<java.lang.Object,java.lang.Object> x$1)
-
getAndClearInstrumentationContext
java.lang.Object getAndClearInstrumentationContext(long seqNr)
-
snapshotterId
java.lang.String snapshotterId()
ReturnspersistenceId.- Specified by:
snapshotterIdin interfaceSnapshotter
-
lastSequenceNr
long lastSequenceNr()
Highest received sequence number so far or0Lif this actor hasn't replayed or stored any persistent events yet.
-
snapshotSequenceNr
long snapshotSequenceNr()
ReturnslastSequenceNr.- Specified by:
snapshotSequenceNrin interfaceSnapshotter
-
onReplaySuccess
void onReplaySuccess()
INTERNAL API. Called whenever a message replay succeeds. May be implemented by subclass.
-
onRecoveryFailureAndInstrumentation
void onRecoveryFailureAndInstrumentation(java.lang.Throwable cause, scala.Option<java.lang.Object> event)
-
onRecoveryFailure
void onRecoveryFailure(java.lang.Throwable cause, scala.Option<java.lang.Object> event)Called whenever a message replay fails. By default it logs the error.Subclass may override to customize logging.
The actor is always stopped after this method has been invoked.
- Parameters:
cause- failure cause.event- the event that was processed inreceiveRecover, if the exception was thrown there
-
onPersistFailure
void onPersistFailure(java.lang.Throwable cause, java.lang.Object event, long seqNr)Called when persist fails. By default it logs the error. Subclass may override to customize logging and for example send negative acknowledgment to sender.The actor is always stopped after this method has been invoked.
Note that the event may or may not have been saved, depending on the type of failure.
- Parameters:
cause- failure cause.event- the event that was to be persisted
-
onPersistRejected
void onPersistRejected(java.lang.Throwable cause, java.lang.Object event, long seqNr)Called when the journal rejectedpersistof an event. The event was not stored. By default this method logs the problem as an error, and the actor continues. The callback handler that was passed to thepersistmethod will not be invoked.- Parameters:
cause- failure causeevent- the event that was to be persisted
-
stashInternally
void stashInternally(java.lang.Object currMsg)
-
unstashInternally
void unstashInternally(boolean all)
-
startRecovery
void startRecovery(Recovery recovery)
-
aroundReceive
void aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, java.lang.Object message)INTERNAL API.- Specified by:
aroundReceivein interfaceActor- Parameters:
receive- current behavior.message- current message.
-
aroundPreStart
void aroundPreStart()
INTERNAL API.- Specified by:
aroundPreStartin interfaceActor
-
requestRecoveryPermit
void requestRecoveryPermit()
-
aroundPreRestart
void aroundPreRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message)INTERNAL API.- Specified by:
aroundPreRestartin interfaceActor
-
aroundPostRestart
void aroundPostRestart(java.lang.Throwable reason)
INTERNAL API.- Specified by:
aroundPostRestartin interfaceActor
-
aroundPostStop
void aroundPostStop()
INTERNAL API.- Specified by:
aroundPostStopin interfaceActor
-
unhandled
void unhandled(java.lang.Object message)
Description copied from interface:ActorUser overridable callback. Is called when a message isn't handled by the current behavior of the actor by default it fails with either aDeathPactException(in case of an unhandledTerminatedmessage) or publishes anUnhandledMessageto the actor's system'sEventStream
-
changeState
void changeState(Eventsourced.State state)
-
updateLastSequenceNr
void updateLastSequenceNr(PersistentRepr persistent)
-
setLastSequenceNr
void setLastSequenceNr(long value)
-
nextSequenceNr
long nextSequenceNr()
-
flushJournalBatch
void flushJournalBatch()
-
sendBatchedEventsToJournal
void sendBatchedEventsToJournal(scala.collection.immutable.Vector<PersistentEnvelope> journalBatch)
-
log
LoggingAdapter log()
-
receiveRecover
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveRecover()
Recovery handler that receives persisted events during recovery. If a state snapshot has been captured and saved, this handler will receive aSnapshotOffermessage followed by events that are younger than the offered snapshot.This handler must not have side-effects other than changing persistent actor state i.e. it should not perform actions that may fail, such as interacting with external services, for example.
If there is a problem with recovering the state of the actor from the journal, the error will be logged and the actor will be stopped.
- See Also:
Recovery
-
receiveCommand
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveCommand()
Command handler. Typically validates commands against current state (and/or by communication with other actors). On successful validation, one or more events are derived from a command and these events are then persisted by callingpersist.
-
internalPersist
<A> void internalPersist(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal API
-
currentCommand
java.lang.Object currentCommand()
-
internalPersistAll
<A> void internalPersistAll(scala.collection.immutable.Seq<A> events, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal API
-
batchAtomicWrite
void batchAtomicWrite(AtomicWrite atomicWrite)
-
internalPersistAsync
<A> void internalPersistAsync(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal API
-
internalPersistAllAsync
<A> void internalPersistAllAsync(scala.collection.immutable.Seq<A> events, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal API
-
internalDeferAsync
<A> void internalDeferAsync(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal API
-
internalDefer
<A> void internalDefer(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Internal API
-
deleteMessages
void deleteMessages(long toSequenceNr)
Permanently deletes all persistent messages with sequence numbers less than or equaltoSequenceNr.If the delete is successful a
DeleteMessagesSuccesswill be sent to the actor. If the delete fails aDeleteMessagesFailurewill be sent to the actor.The given
toSequenceNrmust be less than or equal tolastSequenceNr(), otherwiseDeleteMessagesFailureis sent to the actor without performing the delete. All persistent messages may be deleted without specifying the actual sequence number by usingLong.MaxValueas thetoSequenceNr.- Parameters:
toSequenceNr- upper sequence number (inclusive) bound of persistent messages to be deleted.
-
internalDeleteMessagesBeforeSnapshot
void internalDeleteMessagesBeforeSnapshot(SaveSnapshotSuccess e, int keepNrOfBatches, int snapshotAfter)
INTERNAL API. AnEventsourcedactor can request cleanup by deleting either a range of, or all persistent events. For example, on successful snapshot completion, delete messages within a configurablesnapshotAfterrange that are less than or equal to the givenSnapshotMetadata.sequenceNr(provided theSnapshotMetadata.sequenceNris <= tolastSequenceNr()).Or delete all by using
Long.MaxValueas thetoSequenceNrm.copy(sequenceNr = Long.MaxValue)
-
recoveryRunning
boolean recoveryRunning()
Returnstrueif this persistent actor is currently recovering.
-
recoveryFinished
boolean recoveryFinished()
Returnstrueif this persistent actor has successfully finished recovery.
-
stash
void stash()
Description copied from interface:StashSupportAdds the current message (the message that the actor received last) to the actor's stash.- Specified by:
stashin interfaceStashSupport
-
unstashAll
void unstashAll()
Description copied from interface:StashSupportPrepends all messages in the stash to the mailbox, and then clears the stash.Messages from the stash are enqueued to the mailbox until the capacity of the mailbox (if any) has been reached. In case a bounded mailbox overflows, a
MessageQueueAppendFailedExceptionis thrown.The stash is guaranteed to be empty after calling
unstashAll().- Specified by:
unstashAllin interfaceStashSupport
-
waitingRecoveryPermit
java.lang.Object waitingRecoveryPermit(Recovery recovery)
-
recoveryStarted
java.lang.Object recoveryStarted(long replayMax, scala.concurrent.duration.FiniteDuration timeout)
-
recovering
java.lang.Object recovering(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> recoveryBehavior, scala.concurrent.duration.FiniteDuration timeout)
-
flushBatch
void flushBatch()
-
peekApplyHandler
void peekApplyHandler(java.lang.Object payload)
-
writeEventSucceeded
void writeEventSucceeded(PersistentRepr p)
-
writeEventRejected
void writeEventRejected(PersistentRepr p, java.lang.Throwable cause)
-
writeEventFailed
void writeEventFailed(PersistentRepr p, java.lang.Throwable cause)
-
-