public abstract class UntypedPersistentActor extends UntypedActor implements Eventsourced, PersistenceIdentity
Eventsourced.AsyncHandlerInvocation, Eventsourced.AsyncHandlerInvocation$, Eventsourced.PendingHandlerInvocation, Eventsourced.RecoveryTick, Eventsourced.RecoveryTick$, Eventsourced.StashingHandlerInvocation, Eventsourced.StashingHandlerInvocation$, Eventsourced.StateActor.emptyBehavior$, Actor.ignoringBehavior$| Constructor and Description |
|---|
UntypedPersistentActor() |
| Modifier and Type | Method and Description |
|---|---|
<A> void |
deferAsync(A event,
Procedure<A> handler)
Defer the handler execution until all pending handlers have been executed.
|
protected ActorRef |
journal() |
DequeBasedMessageQueueSemantics |
mailbox() |
void |
onReceive(java.lang.Object message)
To be implemented by concrete UntypedActor, this defines the behavior of the
UntypedActor.
|
abstract void |
onReceiveCommand(java.lang.Object msg)
Java API: command handler.
|
abstract void |
onReceiveRecover(java.lang.Object msg)
Java API: recovery handler that receives persisted events during recovery.
|
<A> void |
persist(A event,
Procedure<A> handler)
Java API: asynchronously persists
event. |
<A> void |
persist(java.lang.Iterable<A> events,
Procedure<A> handler)
Deprecated.
use persistAll instead. Since 2.4.
|
<A> void |
persistAll(java.lang.Iterable<A> events,
Procedure<A> handler)
Java API: asynchronously persists
events in specified order. |
<A> void |
persistAllAsync(java.lang.Iterable<A> events,
Procedure<A> handler)
JAVA API: asynchronously persists
events in specified order. |
<A> void |
persistAsync(A event,
Procedure<A> handler)
JAVA API: asynchronously persists
event. |
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.
|
protected ActorRef |
snapshotStore()
Snapshot store plugin actor.
|
context, getContext, getSelf, getSender, postRestart, postStop, preRestart, preStart, receive, self, supervisorStrategy, unhandledclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, changeState, deferAsync, deleteMessages, flushBatch, flushJournalBatch, lastSequenceNr, log, nextSequenceNr, onPersistFailure, onPersistRejected, onRecoveryFailure, onReplaySuccess, peekApplyHandler, persist, persist, persistAll, persistAllAsync, persistAsync, persistAsync, recovering, recoveryFinished, recoveryRunning, recoveryStarted, requestRecoveryPermit, setLastSequenceNr, snapshotSequenceNr, snapshotterId, startRecovery, stashInternally, unhandled, unstashAll, unstashInternally, updateLastSequenceNr, waitingRecoveryPermitdeleteSnapshot, deleteSnapshots, loadSnapshot, saveSnapshotinternalStashOverflowStrategycontext, postRestart, preStart, receive, self, sender, supervisorStrategyactorCell, clearStash, context, enqueueFirst, prepend, self, stash, unstash, unstashAllcreateStashjournalPluginId, persistenceId, snapshotPluginIdrecoveryprotected ActorRef journal()
journal in interface Eventsourcedprotected ActorRef snapshotStore()
SnapshottersnapshotStore in interface EventsourcedsnapshotStore in interface Snapshotterpublic DequeBasedMessageQueueSemantics mailbox()
mailbox in interface StashSupportpublic final void onReceive(java.lang.Object message)
UntypedActoronReceive in class UntypedActormessage - (undocumented)public final scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveRecover()
EventsourcedSnapshotOffer 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.
receiveRecover in interface EventsourcedRecoverypublic final scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveCommand()
Eventsourcedpersist.receiveCommand in interface Eventsourcedpublic <A> void persist(A event,
Procedure<A> handler)
event. 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 to persist and the execution of its handler. This also holds for
multiple persist calls per received command. Internally, this is achieved by stashing new
commands and unstashing them when the event 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. The getSender() of a persisted
event is the sender of the corresponding command. This means that one can reply to a command
sender within an event handler.
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 even 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.
event - event to be persisted.handler - handler for each persisted eventpublic <A> void persistAll(java.lang.Iterable<A> events,
Procedure<A> handler)
events in specified order. This is equivalent to calling
persist[A](event: A, handler: Procedure[A]) multiple times with the same handler,
except that events are persisted atomically with this method.
events - events to be persisted.handler - handler for each persisted eventspublic <A> void persist(java.lang.Iterable<A> events,
Procedure<A> handler)
public <A> void persistAsync(A event,
Procedure<A> handler)
event. On successful persistence, handler is called with the
persisted event.
Unlike persist the persistent actor will continue to receive incoming commands between the
call to persist and executing it's handler. 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 plain persist(A, akka.japi.Procedure<A>) method.
An event handler may close over persistent actor state and modify it. The sender of a persisted
event is the sender of the corresponding command. This means that one can reply to a command
sender within an event handler.
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 even 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.
event - event to be persistedhandler - handler for each persisted eventpublic <A> void persistAllAsync(java.lang.Iterable<A> events,
Procedure<A> handler)
events in specified order. This is equivalent to calling
persistAsync[A](event: A)(handler: A => Unit) multiple times with the same handler,
except that events are persisted atomically with this method.
events - events to be persistedhandler - handler for each persisted eventspublic <A> void deferAsync(A event,
Procedure<A> handler)
persistAsync calls. That is, if persistAsync was invoked before defer,
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 use persist or persistAsync,
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.
event - event to be handled in the future, when preceding persist operations have been processeshandler - handler for the given eventpublic abstract void onReceiveRecover(java.lang.Object msg)
throws java.lang.Throwable
SnapshotOffer 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.
msg - (undocumented)java.lang.ThrowableRecoverypublic abstract void onReceiveCommand(java.lang.Object msg)
throws java.lang.Throwable
persist.msg - (undocumented)java.lang.Throwable