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
PersistentActor
andAbstractPersistentActor
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Eventsourced.AsyncHandlerInvocation
INTERNAL API: does not force the actor to stash commands; Originates from either `persistAsync` or `defer` callsstatic class
Eventsourced.AsyncHandlerInvocation$
static interface
Eventsourced.PendingHandlerInvocation
INTERNAL APIstatic class
Eventsourced.RecoveryTick
INTERNAL API: message used to detect that recovery timed outstatic class
Eventsourced.RecoveryTick$
static class
Eventsourced.StashingHandlerInvocation
INTERNAL API: forces actor to stash incoming commands until all these invocations are handledstatic class
Eventsourced.StashingHandlerInvocation$
static interface
Eventsourced.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)
void
aroundPostRestart(java.lang.Throwable reason)
INTERNAL API.void
aroundPostStop()
INTERNAL API.void
aroundPreRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message)
INTERNAL API.void
aroundPreStart()
INTERNAL API.void
aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, java.lang.Object message)
INTERNAL API.void
batchAtomicWrite(AtomicWrite atomicWrite)
void
changeState(Eventsourced.State state)
java.lang.Object
currentCommand()
void
currentState_$eq(Eventsourced.State x$1)
void
deleteMessages(long toSequenceNr)
Permanently deletes all persistent messages with sequence numbers less than or equaltoSequenceNr
.void
eventBatch_$eq(scala.collection.immutable.List<PersistentEnvelope> x$1)
void
flushBatch()
void
flushJournalBatch()
java.lang.Object
getAndClearInstrumentationContext(long seqNr)
void
instrumentationContexts_$eq(scala.collection.immutable.Map<java.lang.Object,java.lang.Object> x$1)
<A> void
internalDefer(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)
Internal API<A> void
internalDeferAsync(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)
Internal APIvoid
internalDeleteMessagesBeforeSnapshot(SaveSnapshotSuccess e, int keepNrOfBatches, int snapshotAfter)
INTERNAL API.<A> void
internalPersist(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)
Internal API<A> void
internalPersistAll(scala.collection.immutable.Seq<A> events, scala.Function1<A,scala.runtime.BoxedUnit> handler)
Internal API<A> void
internalPersistAllAsync(scala.collection.immutable.Seq<A> events, scala.Function1<A,scala.runtime.BoxedUnit> handler)
Internal API<A> void
internalPersistAsync(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)
Internal APIActorRef
journal()
void
journalBatch_$eq(scala.collection.immutable.Vector<PersistentEnvelope> x$1)
long
lastSequenceNr()
Highest received sequence number so far or0L
if this actor hasn't replayed or stored any persistent events yet.LoggingAdapter
log()
long
nextSequenceNr()
void
onPersistFailure(java.lang.Throwable cause, java.lang.Object event, long seqNr)
Called when persist fails.void
onPersistRejected(java.lang.Throwable cause, java.lang.Object event, long seqNr)
Called when the journal rejectedpersist
of an event.void
onRecoveryFailure(java.lang.Throwable cause, scala.Option<java.lang.Object> event)
Called whenever a message replay fails.void
onRecoveryFailureAndInstrumentation(java.lang.Throwable cause, scala.Option<java.lang.Object> event)
void
onReplaySuccess()
INTERNAL API.void
peekApplyHandler(java.lang.Object payload)
void
pendingStashingPersistInvocations_$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.Object
recovering(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> recoveryBehavior, scala.concurrent.duration.FiniteDuration timeout)
boolean
recoveryFinished()
Returnstrue
if this persistent actor has successfully finished recovery.boolean
recoveryRunning()
Returnstrue
if this persistent actor is currently recovering.java.lang.Object
recoveryStarted(long replayMax, scala.concurrent.duration.FiniteDuration timeout)
void
requestRecoveryPermit()
void
sendBatchedEventsToJournal(scala.collection.immutable.Vector<PersistentEnvelope> journalBatch)
void
sequenceNr_$eq(long x$1)
void
setLastSequenceNr(long value)
long
snapshotSequenceNr()
ReturnslastSequenceNr
.ActorRef
snapshotStore()
Snapshot store plugin actor.java.lang.String
snapshotterId()
ReturnspersistenceId
.void
startRecovery(Recovery recovery)
void
stash()
Adds the current message (the message that the actor received last) to the actor's stash.void
stashInternally(java.lang.Object currMsg)
void
super$aroundPostRestart(java.lang.Throwable reason)
INTERNAL API.void
super$aroundPostStop()
INTERNAL API.void
super$aroundPreRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message)
INTERNAL API.void
super$aroundPreStart()
void
super$aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, java.lang.Object msg)
Processes a loaded snapshot, if any.void
super$stash()
Returnstrue
if this persistent actor has successfully finished recovery.void
super$unhandled(java.lang.Object message)
void
unhandled(java.lang.Object message)
User overridable callback.void
unstashAll()
Prepends all messages in the stash to the mailbox, and then clears the stash.void
unstashInternally(boolean all)
void
updateLastSequenceNr(PersistentRepr persistent)
java.lang.Object
waitingRecoveryPermit(Recovery recovery)
void
writeEventFailed(PersistentRepr p, java.lang.Throwable cause)
void
writeEventRejected(PersistentRepr p, java.lang.Throwable cause)
void
writeEventSucceeded(PersistentRepr p)
void
writeInProgress_$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()
Returnstrue
if 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 aSnapshotOffer
message to the actor'sreceiveRecover
. Then initiates a message replay, either starting from the loaded snapshot or from scratch, and switches torecoveryStarted
state. 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:Snapshotter
Snapshot store plugin actor.- Specified by:
snapshotStore
in 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:
snapshotterId
in interfaceSnapshotter
-
lastSequenceNr
long lastSequenceNr()
Highest received sequence number so far or0L
if this actor hasn't replayed or stored any persistent events yet.
-
snapshotSequenceNr
long snapshotSequenceNr()
ReturnslastSequenceNr
.- Specified by:
snapshotSequenceNr
in 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 rejectedpersist
of 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 thepersist
method 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:
aroundReceive
in interfaceActor
- Parameters:
receive
- current behavior.message
- current message.
-
aroundPreStart
void aroundPreStart()
INTERNAL API.- Specified by:
aroundPreStart
in interfaceActor
-
requestRecoveryPermit
void requestRecoveryPermit()
-
aroundPreRestart
void aroundPreRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message)
INTERNAL API.- Specified by:
aroundPreRestart
in interfaceActor
-
aroundPostRestart
void aroundPostRestart(java.lang.Throwable reason)
INTERNAL API.- Specified by:
aroundPostRestart
in interfaceActor
-
aroundPostStop
void aroundPostStop()
INTERNAL API.- Specified by:
aroundPostStop
in interfaceActor
-
unhandled
void unhandled(java.lang.Object message)
Description copied from interface:Actor
User 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 unhandledTerminated
message) or publishes anUnhandledMessage
to 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 aSnapshotOffer
message 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
DeleteMessagesSuccess
will be sent to the actor. If the delete fails aDeleteMessagesFailure
will be sent to the actor.The given
toSequenceNr
must be less than or equal tolastSequenceNr()
, otherwiseDeleteMessagesFailure
is sent to the actor without performing the delete. All persistent messages may be deleted without specifying the actual sequence number by usingLong.MaxValue
as 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. AnEventsourced
actor can request cleanup by deleting either a range of, or all persistent events. For example, on successful snapshot completion, delete messages within a configurablesnapshotAfter
range that are less than or equal to the givenSnapshotMetadata.sequenceNr
(provided theSnapshotMetadata.sequenceNr
is <= tolastSequenceNr()
).Or delete all by using
Long.MaxValue
as thetoSequenceNr
m.copy(sequenceNr = Long.MaxValue)
-
recoveryRunning
boolean recoveryRunning()
Returnstrue
if this persistent actor is currently recovering.
-
recoveryFinished
boolean recoveryFinished()
Returnstrue
if this persistent actor has successfully finished recovery.
-
stash
void stash()
Description copied from interface:StashSupport
Adds the current message (the message that the actor received last) to the actor's stash.- Specified by:
stash
in interfaceStashSupport
-
unstashAll
void unstashAll()
Description copied from interface:StashSupport
Prepends 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
MessageQueueAppendFailedException
is thrown.The stash is guaranteed to be empty after calling
unstashAll()
.- Specified by:
unstashAll
in 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)
-
-