Event log actor.
Event log actor.
Global unique actor id.
Global unique actor id.
Command handler.
Command handler.
Event handler.
Event handler.
Optional aggregate id.
Optional aggregate id. It is used for routing DurableEvents to event-sourced destinations
which can be EventsourcedViews or EventsourcedActors. By default, an event is routed
to an event-sourced destination with an undefined aggregateId
. If a destination's aggregateId
is defined it will only receive events with a matching aggregate id in
DurableEvent#destinationAggregateIds.
Delays handling of command
to that point in the future where all previously called persist
or persistN
operations completed.
Delays handling of command
to that point in the future where all previously called persist
or persistN
operations completed. Therefore, using this method only makes sense if stateSync
is set to false
. The handler
is called during a separate message dispatch by this actor,
hence, it is safe to access internal state within handler
.
Internal API.
Internal API.
Internal API.
Internal API.
Internal API.
Internal API.
Emitter aggregate id of the last handled event.
Emitter aggregate id of the last handled event.
Emitter id of the last handled event.
Emitter id of the last handled event.
Sequence number of the last handled event.
Sequence number of the last handled event.
Wall-clock timestamp of the last handled event.
Wall-clock timestamp of the last handled event.
Vector timestamp of the last handled event.
Vector timestamp of the last handled event.
Sends a LoadSnapshot command to the event log.
Sends a LoadSnapshot command to the event log. Can be overridden by implementations to customize snapshot loading.
Called after recovery successfully completed.
Called after recovery successfully completed. Can be overridden by implementations.
Snapshot handler.
Snapshot handler.
Asynchronously persists the given event
and calls handler
with the persist result.
Asynchronously persists the given event
and calls handler
with the persist result.
The handler
is called during a separate message dispatch by this actor, hence, it is
safe to modify internal state within handler
. The handler
can also obtain a reference
to the initial command sender via sender()
.
By default, the event is routed to event-sourced destinations with an undefined aggregateId
.
If this actor's aggregateId
is defined it is additionally routed to all actors with the same
aggregateId
. Further routing destinations can be defined with the customDestinationAggregateIds
parameter.
Asynchronously persists a sequence of events
and calls handler
with the persist
results.
Asynchronously persists a sequence of events
and calls handler
with the persist
results. The handler
is called for each event in the sequence during a separate
message dispatch by this actor, hence, it is safe to modify internal state within
handler
. The handler
can also obtain a reference to the initial command sender
via sender()
. The onLast
handler is additionally called for the last event in
the sequence.
By default, the event is routed to event-sourced destinations with an undefined aggregateId
.
If this actor's aggregateId
is defined it is additionally routed to all actors with the same
aggregateId
. Further routing destinations can be defined with the customDestinationAggregateIds
parameter.
Asynchronously persists the event returned by f
and calls handler
with the persist
result.
Asynchronously persists the event returned by f
and calls handler
with the persist
result. The input parameter to f
is the current local time which is the actor's logical
time, taken from its internal vector clock, and not the current system time. The handler
is called during a separate message dispatch by this actor, hence, it is safe to modify
internal state within handler
. The handler
can also obtain a reference to the initial
command sender via sender()
.
By default, the event is routed to event-sourced destinations with an undefined aggregateId
.
If this actor's aggregateId
is defined it is additionally routed to all actors with the same
aggregateId
. Further routing destinations can be defined with the customDestinationAggregateIds
parameter.
Initiates recovery by calling load.
Initiates recovery by calling load.
Initialization behavior.
Initialization behavior.
Returns true
if this actor is currently recovering internal state by consuming
replayed events from the event log.
Returns true
if this actor is currently recovering internal state by consuming
replayed events from the event log. Returns false
after recovery completed and
the actor switches to consuming live events.
Sends a Replay command to the event log.
Sends a Replay command to the event log. Can be overridden by implementations to customize replay.
Asynchronously saves the given snapshot
and calls handler
with the generated
snapshot metadata.
Asynchronously saves the given snapshot
and calls handler
with the generated
snapshot metadata. The handler
can also obtain a reference to the initial message
sender via sender()
.
State synchronization.
State synchronization. If set to true
, commands see internal state that is
consistent with the event log. This is achieved by stashing new commands if this actor
is currently writing events.
If set to false
, commands see internal state that might be stale. To see state updates
from any previously persisted events, applications can delay
these commands. In this mode,
commands are not stashed and events can be batched for write which significantly increases
write throughput.
An
EventsourcedActor
is an EventsourcedView that can also produce (= emit) new events to its event log. New events can be produced with methodspersist
,persistN
andpersistWithLocalTime
. They must only be used within theonCommand
command handler. The command handler may only read internal state but must not modify it. Internal state may only be modified withinonEvent
.An
EventsourcedActor
maintains a VectorClock used to time-stamp the events it emits to the event log. Events that are handled by its event handler update the vector clock. Events that are pushed from theeventLog
actor but not handled byonEvent
do not update the vector clock.EventsourcedView