Class UntypedPersistentActor
- java.lang.Object
-
- akka.actor.UntypedActor
-
- akka.persistence.UntypedPersistentActor
-
- All Implemented Interfaces:
Actor
,Stash
,StashFactory
,StashSupport
,UnrestrictedStash
,RequiresMessageQueue<DequeBasedMessageQueueSemantics>
,Eventsourced
,PersistenceIdentity
,PersistenceRecovery
,PersistenceStash
,Snapshotter
- Direct Known Subclasses:
UntypedPersistentActorWithAtLeastOnceDelivery
public abstract class UntypedPersistentActor extends UntypedActor implements Eventsourced, PersistenceIdentity
Deprecated.Use AbstractPersistentActor instead of UntypedPersistentActor. Since 2.5.0.Java API: asynchronously persistsevent
. On successful persistence,handler
is called with the persisted event. It is guaranteed that no new commands will be received by a persistent actor between a call topersist
and the execution of itshandler
. This also holds for multiplepersist
calls per received command. Internally, this is achieved by stashing new commands and unstashing them when theevent
has been persisted and handled. The stash used for that is an internal stash which doesn't interfere with the inherited user stash.An event
handler
may close over persistent actor state and modify it. ThegetSender()
of 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.param: event event to be persisted. param: handler handler for each persisted
event
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$
-
Nested classes/interfaces inherited from interface akka.persistence.Eventsourced
Eventsourced.AsyncHandlerInvocation, Eventsourced.AsyncHandlerInvocation$, Eventsourced.PendingHandlerInvocation, Eventsourced.RecoveryTick, Eventsourced.RecoveryTick$, Eventsourced.StashingHandlerInvocation, Eventsourced.StashingHandlerInvocation$, Eventsourced.State
-
-
Constructor Summary
Constructors Constructor Description UntypedPersistentActor()
Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
akka$actor$StashSupport$_setter_$mailbox_$eq(DequeBasedMessageQueueSemantics x$1)
Deprecated.<A> void
defer(A event, Procedure<A> handler)
Deprecated.Defer the handler execution until all pending handlers have been executed.<A> void
deferAsync(A event, Procedure<A> handler)
Deprecated.Defer the handler execution until all pending handlers have been executed.protected ActorRef
journal()
Deprecated.DequeBasedMessageQueueSemantics
mailbox()
Deprecated.void
onReceive(java.lang.Object message)
Deprecated.abstract void
onReceiveCommand(java.lang.Object msg)
Deprecated.Java API: command handler.abstract void
onReceiveRecover(java.lang.Object msg)
Deprecated.Java API: recovery handler that receives persisted events during recovery.<A> void
persist(A event, Procedure<A> handler)
Deprecated.Java API: asynchronously persistsevent
.<A> void
persistAll(java.lang.Iterable<A> events, Procedure<A> handler)
Deprecated.Java API: asynchronously persistsevents
in specified order.<A> void
persistAllAsync(java.lang.Iterable<A> events, Procedure<A> handler)
Deprecated.JAVA API: asynchronously persistsevents
in specified order.<A> void
persistAsync(A event, Procedure<A> handler)
Deprecated.JAVA API: asynchronously persistsevent
.scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
receiveCommand()
Deprecated.Command handler.scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
receiveRecover()
Deprecated.Recovery handler that receives persisted events during recovery.protected ActorRef
snapshotStore()
Deprecated.Snapshot store plugin actor.-
Methods inherited from class akka.actor.UntypedActor
akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, context, getContext, getSelf, getSender, postRestart, postStop, preRestart, preStart, receive, self, supervisorStrategy, unhandled
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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.Eventsourced
_lastSequenceNr_$eq, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, batchAtomicWrite, changeState, currentState_$eq, deleteMessages, eventBatch_$eq, flushBatch, flushJournalBatch, internalDefer, internalDeferAsync, internalDeleteMessagesBeforeSnapshot, internalPersist, internalPersistAll, internalPersistAllAsync, internalPersistAsync, journalBatch_$eq, lastSequenceNr, log, nextSequenceNr, onPersistFailure, onPersistRejected, onRecoveryFailure, onReplaySuccess, peekApplyHandler, pendingStashingPersistInvocations_$eq, recovering, recoveryFinished, recoveryRunning, recoveryStarted, requestRecoveryPermit, sendBatchedEventsToJournal, sequenceNr_$eq, setLastSequenceNr, snapshotSequenceNr, 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.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, clearStash, context, enqueueFirst, prepend, self, theStash_$eq, unstash, unstashAll
-
Methods inherited from interface akka.actor.UnrestrictedStash
postStop, preRestart, super$postStop, super$preRestart
-
-
-
-
Method Detail
-
akka$actor$StashSupport$_setter_$mailbox_$eq
protected void akka$actor$StashSupport$_setter_$mailbox_$eq(DequeBasedMessageQueueSemantics x$1)
Deprecated.- Specified by:
akka$actor$StashSupport$_setter_$mailbox_$eq
in interfaceStashSupport
-
defer
public <A> void defer(A event, Procedure<A> handler)
Deprecated.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 todefer
and the execution of itshandler
. Allows to define logic within the actor, which will respect the invocation-order-guarantee in respect topersistAsync
orpersist
calls. That is, ifpersistAsync
orpersist
was invoked beforedefer
, the corresponding handlers will be invoked in the same order as they were registered in.This call will NOT result in
event
being persisted, usepersist
orpersistAsync
instead 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
handler
will not be run.- Parameters:
event
- event to be handled in the future, when preceding persist operations have been processeshandler
- handler for the givenevent
-
deferAsync
public <A> void deferAsync(A event, Procedure<A> handler)
Deprecated.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 topersistAsync
orpersist
calls. That is, ifpersistAsync
orpersist
was invoked beforedeferAsync
, the corresponding handlers will be invoked in the same order as they were registered in.This call will NOT result in
event
being persisted, please usepersist
orpersistAsync
, 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
handler
will not be run.- Parameters:
event
- event to be handled in the future, when preceding persist operations have been processeshandler
- handler for the givenevent
-
journal
protected ActorRef journal()
Deprecated.- Specified by:
journal
in interfaceEventsourced
-
mailbox
public DequeBasedMessageQueueSemantics mailbox()
Deprecated.- Specified by:
mailbox
in interfaceStashSupport
-
onReceive
public final void onReceive(java.lang.Object message)
Deprecated.- Specified by:
onReceive
in classUntypedActor
-
onReceiveCommand
public abstract void onReceiveCommand(java.lang.Object msg) throws java.lang.Throwable
Deprecated.Java API: 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
.- Parameters:
msg
- (undocumented)- Throws:
java.lang.Throwable
-
onReceiveRecover
public abstract void onReceiveRecover(java.lang.Object msg) throws java.lang.Throwable
Deprecated.Java API: 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.
- Parameters:
msg
- (undocumented)- Throws:
java.lang.Throwable
- See Also:
Recovery
-
persist
public <A> void persist(A event, Procedure<A> handler)
Deprecated.Java API: asynchronously persistsevent
. On successful persistence,handler
is called with the persisted event. It is guaranteed that no new commands will be received by a persistent actor between a call topersist
and the execution of itshandler
. This also holds for multiplepersist
calls per received command. Internally, this is achieved by stashing new commands and unstashing them when theevent
has been persisted and handled. The stash used for that is an internal stash which doesn't interfere with the inherited user stash.An event
handler
may close over persistent actor state and modify it. ThegetSender()
of 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 persistedevent
-
persistAll
public <A> void persistAll(java.lang.Iterable<A> events, Procedure<A> handler)
Deprecated.Java API: asynchronously persistsevents
in specified order. This is equivalent to callingpersist[A](event: A, handler: Procedure[A])
multiple times with the samehandler
, except thatevents
are persisted atomically with this method.- Parameters:
events
- events to be persisted.handler
- handler for each persistedevents
-
persistAllAsync
public <A> void persistAllAsync(java.lang.Iterable<A> events, Procedure<A> handler)
Deprecated.JAVA API: asynchronously persistsevents
in specified order. This is equivalent to callingpersistAsync[A](event: A)(handler: A => Unit)
multiple times with the samehandler
, except thatevents
are persisted atomically with this method.- Parameters:
events
- events to be persistedhandler
- handler for each persistedevents
-
persistAsync
public <A> void persistAsync(A event, Procedure<A> handler)
Deprecated.JAVA API: asynchronously persistsevent
. On successful persistence,handler
is called with the persisted event.Unlike
persist
the persistent actor will continue to receive incoming commands between the call topersist
and 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 plainpersist(A, akka.japi.Procedure<A>)
method.An event
handler
may close over persistent actor state and modify it. Thesender
of 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 persistedhandler
- handler for each persistedevent
-
receiveCommand
public final scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveCommand()
Deprecated.Description copied from interface:Eventsourced
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
.- Specified by:
receiveCommand
in interfaceEventsourced
- Returns:
- (undocumented)
-
receiveRecover
public final scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveRecover()
Deprecated.Description copied from interface:Eventsourced
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.
- Specified by:
receiveRecover
in interfaceEventsourced
- Returns:
- (undocumented)
- See Also:
Recovery
-
snapshotStore
protected ActorRef snapshotStore()
Deprecated.Description copied from interface:Snapshotter
Snapshot store plugin actor.- Specified by:
snapshotStore
in interfaceEventsourced
- Specified by:
snapshotStore
in interfaceSnapshotter
-
-