|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object akka.actor.AbstractActor akka.persistence.AbstractPersistentActor
public abstract class AbstractPersistentActor
Java API: an persistent actor - can be used to implement command or event sourcing.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface akka.persistence.Eventsourced |
---|
Eventsourced.PendingHandlerInvocation |
Nested classes/interfaces inherited from interface akka.persistence.Recovery |
---|
Recovery.State |
Nested classes/interfaces inherited from interface akka.actor.Actor |
---|
Actor.emptyBehavior$ |
Constructor Summary | |
---|---|
AbstractPersistentActor()
|
Method Summary | ||
---|---|---|
|
defer(A event,
Procedure<A> handler)
Defer the handler execution until all pending handlers have been executed. |
|
|
defer(java.lang.Iterable<A> events,
Procedure<A> handler)
Defer the handler execution until all pending handlers have been executed. |
|
|
persist(A event,
Procedure<A> handler)
Java API: asynchronously persists event . |
|
|
persist(java.lang.Iterable<A> events,
Procedure<A> handler)
Java API: asynchronously persists events in specified order. |
|
|
persistAsync(A event,
Procedure<A> handler)
Java API: asynchronously persists event . |
|
|
persistAsync(java.lang.Iterable<A> events,
Procedure<A> handler)
Java API: asynchronously persists events in specified order. |
|
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
receive()
This defines the initial actor behavior, it must return a partial function with the actor logic. |
Methods inherited from class akka.actor.AbstractActor |
---|
emptyBehavior, getContext, receive |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface akka.persistence.Eventsourced |
---|
aroundPreRestart, aroundReceive, currentState, defer, defer, flushBatch, initialBehavior, pendingInvocations, pendingStashingPersistInvocations, persist, persist, persistAsync, persistAsync, persistingEvents, postStop, preRestart, processingCommands, processorStash, receiveCommand, receiveRecover, recovering, recoveryBehavior, resequenceableEventBatch, unstashAll, useProcessorBatching |
Methods inherited from interface akka.persistence.ProcessorImpl |
---|
_persistenceId, aroundPostStop, aroundPreStart, deleteMessage, deleteMessage, deleteMessages, deleteMessages, flushJournalBatch, initializing, instanceId, nextSequenceNr, onRecoveryCompleted, onRecoveryFailure, onReplayFailure, onReplaySuccess, preRestartDefault, preStart, processing, processorBatch, processorId, recoveryFinished, recoveryRunning, sequenceNr, snapshotterId, unhandled, unstashFilterPredicate |
Methods inherited from interface akka.persistence.Recovery |
---|
_currentPersistent, _currentState, _lastSequenceNr, _recoveryFailureCause, _recoveryFailureMessage, currentPersistentMessage, extension, getCurrentPersistentMessage, journal, lastSequenceNr, persistenceId, prepareRestart, receiverStash, recoveryPending, recoveryStarted, replayFailed, replayStarted, runReceive, snapshotSequenceNr, updateLastSequenceNr, updateLastSequenceNr, withCurrentPersistent |
Methods inherited from interface akka.persistence.Snapshotter |
---|
deleteSnapshot, deleteSnapshots, loadSnapshot, saveSnapshot, snapshotStore |
Methods inherited from interface akka.actor.Actor |
---|
aroundPostRestart, context, postRestart, self, sender, supervisorStrategy |
Methods inherited from interface akka.actor.StashSupport |
---|
actorCell, capacity, clearStash, context, enqueueFirst, mailbox, prepend, self, stash, theStash, unstash, unstashAll |
Methods inherited from interface akka.actor.StashFactory |
---|
createStash |
Constructor Detail |
---|
public AbstractPersistentActor()
Method Detail |
---|
public final <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, the persistent actor will be stopped. This can be customized by
handling PersistenceFailure
in receiveCommand
.
event
- event to be persisted.handler
- handler for each persisted event
public final <A> void persist(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 events
public final <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 incomming 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, the persistent actor will be stopped. This can be customized by
handling PersistenceFailure
in receiveCommand
.
event
- event to be persistedhandler
- handler for each persisted event
public final <A> void defer(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 immediatly.
In the event of persistence failures (indicated by PersistenceFailure
messages being sent to the
PersistentActor
, you can handle these messages, which in turn will enable the deferred handlers to run afterwards.
If persistence failure messages are left unhandled
, the default behavior is to stop the Actor, thus the handlers
will not be run.
event
- event to be handled in the future, when preceeding persist operations have been processeshandler
- handler for the given event
public final <A> void defer(java.lang.Iterable<A> events, 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 immediatly.
In the event of persistence failures (indicated by PersistenceFailure
messages being sent to the
PersistentActor
, you can handle these messages, which in turn will enable the deferred handlers to run afterwards.
If persistence failure messages are left unhandled
, the default behavior is to stop the Actor, thus the handlers
will not be run.
events
- event to be handled in the future, when preceeding persist operations have been processeshandler
- handler for each event
public final <A> void persistAsync(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 events
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Actor
receive
in interface Actor
receive
in interface PersistentActor
receive
in class AbstractActor
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |