public abstract class AbstractPersistentActor extends akka.actor.AbstractActor implements PersistentActor, Eventsourced
Eventsourced.AsyncHandlerInvocation, Eventsourced.AsyncHandlerInvocation$, Eventsourced.PendingHandlerInvocation, Eventsourced.StashingHandlerInvocation, Eventsourced.StashingHandlerInvocation$, Eventsourced.State
Constructor and Description |
---|
AbstractPersistentActor() |
Modifier and Type | Method and Description |
---|---|
<A> void |
deferAsync(A event,
akka.japi.Procedure<A> handler)
Defer the handler execution until all pending handlers have been executed.
|
<A> void |
persist(A event,
akka.japi.Procedure<A> handler)
Java API: asynchronously persists
event . |
<A> void |
persist(java.lang.Iterable<A> events,
akka.japi.Procedure<A> handler) |
<A> void |
persistAll(java.lang.Iterable<A> events,
akka.japi.Procedure<A> handler)
Java API: asynchronously persists
events in specified order. |
<A> void |
persistAllAsync(java.lang.Iterable<A> events,
akka.japi.Procedure<A> handler)
Java API: asynchronously persists
events in specified order. |
<A> void |
persistAsync(A event,
akka.japi.Procedure<A> handler)
Java API: asynchronously persists
event . |
<A> void |
persistAsync(java.lang.Iterable<A> events,
akka.japi.Procedure<A> handler) |
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
receive() |
akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, emptyBehavior, getContext, postRestart, postStop, preRestart, preStart, receive, self, sender, supervisorStrategy, unhandled
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
_lastSequenceNr, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, changeState, currentState, deferAsync, deleteMessages, eventBatch, extension, flushBatch, flushJournalBatch, instanceId, internalStash, journal, journalBatch, lastSequenceNr, log, maxMessageBatchSize, nextSequenceNr, onPersistFailure, onPersistRejected, onRecoveryFailure, onReplaySuccess, peekApplyHandler, pendingInvocations, pendingStashingPersistInvocations, persist, persist, persistAll, persistAllAsync, persistAsync, persistAsync, persistingEvents, processingCommands, receiveCommand, receiveRecover, recovering, recoveryFinished, recoveryRunning, recoveryStarted, sequenceNr, setLastSequenceNr, snapshotSequenceNr, snapshotStore, snapshotterId, startRecovery, unhandled, unstashAll, unstashFilterPredicate, updateLastSequenceNr, writeInProgress, writerUuid
deleteSnapshot, deleteSnapshots, loadSnapshot, saveSnapshot
akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, context, postRestart, preStart, self, sender, supervisorStrategy
akka$actor$StashSupport$_setter_$akka$actor$StashSupport$$capacity_$eq, akka$actor$StashSupport$_setter_$mailbox_$eq, akka$actor$StashSupport$$capacity, akka$actor$StashSupport$$theStash_$eq, akka$actor$StashSupport$$theStash, clearStash, context, mailbox, prepend, self, stash, unstash, unstashAll
journalPluginId, persistenceId, snapshotPluginId
recovery
public <A> void persist(A event, akka.japi.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 event
public <A> void persistAll(java.lang.Iterable<A> events, akka.japi.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 events
public <A> void persist(java.lang.Iterable<A> events, akka.japi.Procedure<A> handler)
public <A> void persistAsync(A event, akka.japi.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 persistAsync
and executing it's handler
. This asynchronous, non-stashing, version of
of persist should be used when you favor throughput over the strict ordering guarantees that persist
guarantees.
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 event
public <A> void persistAllAsync(java.lang.Iterable<A> events, akka.japi.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 events
public <A> void persistAsync(java.lang.Iterable<A> events, akka.japi.Procedure<A> handler)
public <A> void deferAsync(A event, akka.japi.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 event
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
receive
in interface akka.actor.Actor
receive
in interface PersistentActor
receive
in class akka.actor.AbstractActor