Interface PersistentActor
- 
- All Superinterfaces:
- Actor,- Eventsourced,- PersistenceIdentity,- PersistenceRecovery,- PersistenceStash,- RequiresMessageQueue<DequeBasedMessageQueueSemantics>,- Snapshotter,- Stash,- StashFactory,- StashSupport,- UnrestrictedStash
 - All Known Subinterfaces:
- AtLeastOnceDelivery
 - All Known Implementing Classes:
- JournalPerfSpec.BenchActor,- PersistentShardCoordinator
 
 public interface PersistentActor extends Eventsourced, PersistenceIdentity Scala API: A persistent Actor - can be used to implement command or Event Sourcing.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface akka.actor.ActorActor.emptyBehavior$, Actor.ignoringBehavior$
 - 
Nested classes/interfaces inherited from interface akka.persistence.EventsourcedEventsourced.AsyncHandlerInvocation, Eventsourced.AsyncHandlerInvocation$, Eventsourced.PendingHandlerInvocation, Eventsourced.RecoveryTick, Eventsourced.RecoveryTick$, Eventsourced.StashingHandlerInvocation, Eventsourced.StashingHandlerInvocation$, Eventsourced.State
 
- 
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description <A> voiddefer(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Defer the handler execution until all pending handlers have been executed.<A> voiddeferAsync(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Defer the handler execution until all pending handlers have been executed.<A> voidpersist(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Asynchronously persistsevent.<A> voidpersistAll(scala.collection.immutable.Seq<A> events, scala.Function1<A,scala.runtime.BoxedUnit> handler)Asynchronously persistseventsin specified order.<A> voidpersistAllAsync(scala.collection.immutable.Seq<A> events, scala.Function1<A,scala.runtime.BoxedUnit> handler)Asynchronously persistseventsin specified order.<A> voidpersistAsync(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Asynchronously persistsevent.scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>receive()Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.- 
Methods inherited from interface akka.actor.Actorakka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, context, postRestart, preStart, self, sender, supervisorStrategy
 - 
Methods inherited from interface akka.persistence.Eventsourced_lastSequenceNr_$eq, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, batchAtomicWrite, changeState, currentCommand, currentState_$eq, deleteMessages, eventBatch_$eq, flushBatch, flushJournalBatch, getAndClearInstrumentationContext, instrumentationContexts_$eq, internalDefer, internalDeferAsync, internalDeleteMessagesBeforeSnapshot, internalPersist, internalPersistAll, internalPersistAllAsync, internalPersistAsync, journal, journalBatch_$eq, lastSequenceNr, log, nextSequenceNr, onPersistFailure, onPersistRejected, onRecoveryFailure, onRecoveryFailureAndInstrumentation, onReplaySuccess, peekApplyHandler, pendingStashingPersistInvocations_$eq, receiveCommand, receiveRecover, recovering, recoveryFinished, recoveryRunning, recoveryStarted, requestRecoveryPermit, sendBatchedEventsToJournal, sequenceNr_$eq, setLastSequenceNr, snapshotSequenceNr, snapshotStore, snapshotterId, startRecovery, stash, stashInternally, super$aroundPostRestart, super$aroundPostStop, super$aroundPreRestart, super$aroundPreStart, super$aroundReceive, super$stash, super$unhandled, unhandled, unstashAll, unstashInternally, updateLastSequenceNr, waitingRecoveryPermit, writeEventFailed, writeEventRejected, writeEventSucceeded, writeInProgress_$eq
 - 
Methods inherited from interface akka.persistence.PersistenceIdentityjournalPluginId, persistenceId, snapshotPluginId
 - 
Methods inherited from interface akka.persistence.PersistenceRecoveryrecovery
 - 
Methods inherited from interface akka.persistence.PersistenceStashinternalStashOverflowStrategy
 - 
Methods inherited from interface akka.persistence.SnapshotterdeleteSnapshot, deleteSnapshots, loadSnapshot, saveSnapshot
 - 
Methods inherited from interface akka.actor.StashFactorycreateStash
 - 
Methods inherited from interface akka.actor.StashSupportactorCell, akka$actor$StashSupport$_setter_$mailbox_$eq, clearStash, context, enqueueFirst, mailbox, prepend, self, theStash_$eq, unstash, unstashAll
 - 
Methods inherited from interface akka.actor.UnrestrictedStashpostStop, preRestart, super$postStop, super$preRestart
 
- 
 
- 
- 
- 
Method Detail- 
defer<A> void defer(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Defer the handler execution until all pending handlers have been executed. It is guaranteed that no new commands will be received by a persistent actor between a call todeferand the execution of itshandler. Allows to define logic within the actor, which will respect the invocation-order-guarantee in respect topersistAsyncorpersistcalls. That is, ifpersistAsyncorpersistwas invoked beforedefer, the corresponding handlers will be invoked in the same order as they were registered in.This call will NOT result in eventbeing persisted, usepersistorpersistAsyncinstead if the given event should possible to replay.If there are no pending persist handler calls, the handler will be called immediately. If persistence of an earlier event fails, the persistent actor will stop, and the handlerwill not be run.- Parameters:
- event- event to be handled in the future, when preceding persist operations have been processes
- handler- handler for the given- event
 
 - 
deferAsync<A> void deferAsync(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Defer the handler execution until all pending handlers have been executed. Allows to define logic within the actor, which will respect the invocation-order-guarantee in respect topersistAsyncorpersistcalls. That is, ifpersistAsyncorpersistwas invoked beforedeferAsync, the corresponding handlers will be invoked in the same order as they were registered in.This call will NOT result in eventbeing persisted, usepersistorpersistAsyncinstead if the given event should possible to replay.If there are no pending persist handler calls, the handler will be called immediately. If persistence of an earlier event fails, the persistent actor will stop, and the handlerwill not be run.- Parameters:
- event- event to be handled in the future, when preceding persist operations have been processes
- handler- handler for the given- event
 
 - 
persist<A> void persist(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Asynchronously persistsevent. On successful persistence,handleris called with the persisted event. It is guaranteed that no new commands will be received by a persistent actor between a call topersistand the execution of itshandler. This also holds for multiplepersistcalls per received command. Internally, this is achieved by stashing new commands and unstashing them when theeventhas been persisted and handled. The stash used for that is an internal stash which doesn't interfere with the inherited user stash.An event handlermay close over persistent actor state and modify it. Thesenderof a persisted event is the sender of the corresponding command. This means that one can reply to a command sender within an eventhandler.Within an event handler, applications usually update persistent actor state using persisted event data, notify listeners and reply to command senders. If persistence of an event fails, Eventsourced.onPersistFailure(java.lang.Throwable, java.lang.Object, long)will be invoked and the actor will unconditionally be stopped. The reason that it cannot resume when persist fails is that it is unknown if the event was actually persisted or not, and therefore it is in an inconsistent state. Restarting on persistent failures will most likely fail anyway, since the journal is probably unavailable. It is better to stop the actor and after a back-off timeout start it again.- Parameters:
- event- event to be persisted
- handler- handler for each persisted- event
 
 - 
persistAll<A> void persistAll(scala.collection.immutable.Seq<A> events, scala.Function1<A,scala.runtime.BoxedUnit> handler)Asynchronously persistseventsin specified order. This is equivalent to callingpersist[A](event: A)(handler: A => Unit)multiple times with the samehandler, except thateventsare persisted atomically with this method.- Parameters:
- events- events to be persisted
- handler- handler for each persisted- events
 
 - 
persistAllAsync<A> void persistAllAsync(scala.collection.immutable.Seq<A> events, scala.Function1<A,scala.runtime.BoxedUnit> handler)Asynchronously persistseventsin specified order. This is equivalent to callingpersistAsync[A](event: A)(handler: A => Unit)multiple times with the samehandler, except thateventsare persisted atomically with this method.- Parameters:
- events- events to be persisted
- handler- handler for each persisted- events
 
 - 
persistAsync<A> void persistAsync(A event, scala.Function1<A,scala.runtime.BoxedUnit> handler)Asynchronously persistsevent. On successful persistence,handleris called with the persisted event.Unlike persistthe persistent actor will continue to receive incoming commands between the call topersistand executing it'shandler. This asynchronous, non-stashing, version of of persist should be used when you favor throughput over the "command-2 only processed after command-1 effects' have been applied" guarantee, which is provided by the plainpersistmethod.An event handlermay close over persistent actor state and modify it. Thesenderof a persisted event is the sender of the corresponding command. This means that one can reply to a command sender within an eventhandler.If persistence of an event fails, Eventsourced.onPersistFailure(java.lang.Throwable, java.lang.Object, long)will be invoked and the actor will unconditionally be stopped. The reason that it cannot resume when persist fails is that it is unknown if the event was actually persisted or not, and therefore it is in an inconsistent state. Restarting on persistent failures will most likely fail anyway, since the journal is probably unavailable. It is better to stop the actor and after a back-off timeout start it again.- Parameters:
- event- event to be persisted
- handler- handler for each persisted- event
 
 
- 
 
-