Event log actor.
Event log actor.
Global unique actor id.
Global unique actor id.
Command handler.
Command handler.
Event handler.
Event handler.
Asynchronously reads an initial value from the target database, usually to obtain information about event processing progress.
Asynchronously reads an initial value from the target database, usually to obtain information about event processing progress. This method is called during initialization.
Asynchronously writes an incremental update to the target database.
Asynchronously writes an incremental update to the target database. Incremental updates are prepared
during event processing by a concrete onEvent
handler.
During event replay, this method is called latest after having replayed eventuate.log.replay-batch-size
events and immediately after replay completes. During live processing, write
is called immediately if
no write operation is in progress and an event has been handled by onEvent
. If a write operation is in
progress, further event handling may run concurrently to that operation. If events are handled while a
write operation is in progress, another write will follow immediately after the previous write operation
completes.
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.
Returns the command BehaviorContext.
Returns the command BehaviorContext.
Returns the event BehaviorContext.
Returns the event BehaviorContext.
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.
Id of the local event log that initially wrote the event.
Id of the local event log that initially wrote the 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.
This actor's logging adapter.
This actor's logging adapter.
Recovery completion handler.
Recovery completion handler. If called with a Failure
, the actor will be stopped in
any case, regardless of the action taken by the returned handler. The default handler
implementation does nothing and can be overridden by implementations.
Snapshot handler.
Snapshot handler.
Sets recovering
to false
before calling super.postStop
.
Sets recovering
to false
before calling super.postStop
.
Sets recovering
to false
before calling super.preRestart
.
Sets recovering
to false
before calling super.preRestart
.
Initiates recovery.
Initiates recovery.
Called with failure details after a read
operation failed.
Called with failure details after a read
operation failed. Throws EventsourcedWriter#ReadException
by default (causing the writer to restart) and can be overridden.
Called with a read result after a read
operation successfully completes.
Called with a read result after a read
operation successfully completes. This method may update
internal actor state. If None
is returned, the writer continues with state recovery by replaying
events, optionally starting from a snapshot. If the return value is defined, replay starts from the
returned sequence number without ever loading a snapshot. Does nothing and returns None
by default
and can be overridden.
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.
Maximum number of events to be replayed to this actor before replaying is suspended.
Maximum number of events to be replayed to this actor before replaying is suspended. A suspended replay
is resumed automatically after all replayed events haven been handled by this actor's event handler
(= backpressure). The default value for the maximum replay batch size is given by configuration item
eventuate.log.replay-batch-size
. Configured values can be overridden by overriding this method.
Disallow for EventsourcedWriter and subclasses as event processing progress is determined by read
and readSuccess
.
Disallow for EventsourcedWriter and subclasses as event processing progress is determined by read
and readSuccess
.
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 obtain a reference to the initial message
sender with sender()
.
Returns the snapshot BehaviorContext.
Returns the snapshot BehaviorContext.
Adds the current command to the user's command stash.
Adds the current command to the user's command stash. Must not be used in the event handler.
Prepends all stashed commands to the actor's mailbox and then clears the command stash.
Prepends all stashed commands to the actor's mailbox and then clears the command stash.
Has no effect if the actor is recovering i.e. if recovering
returns true
.
Called with failure details after a write
operation failed.
Called with failure details after a write
operation failed. Throws EventsourcedWriter#WriteException
by default (causing the writer to restart) and can be overridden.
Called with a write result after a write
operation successfully completes.
Called with a write result after a write
operation successfully completes. This method may update
internal actor state. Does nothing by default and can be overridden.
An EventsourcedView designed to update external databases from events stored in its event log. It supports event processing patterns optimized for batch-updating external databases to create persistent views or read models:
EventsourcedWriter
asynchronouslyread
s data from the external database to obtain information about the actual event processing progress. For example, if the last processed event sequence number is written with every batch update to the database, it can be read during initialization and used by the writer to detect duplicates during further event processing so that event processing can be made idempotent.onEvent
handler, a concrete writer usually builds a database-specific write-batch (representing an incremental update). After a configurable number of events,EventsourcedWriter
callswrite
to asynchronously write the prepared batch to the database.An
EventsourcedWriter
may also implement anonCommand
handler to process commands and save snapshots of internal state. Internal state is recovered by replaying events from the event log, optionally starting from a saved snapshot (see EventsourcedView for details). If a writer doesn't require full internal state recovery, it may define a custom starting position in the event log by returning a sequence number fromreadSuccess
. If full internal state recovery is required instead,readSuccess
should returnNone
(which is the default).Implementation notes:
write
, a writer should clear the prepared write batch so that further events can be processed while the asynchronous write operation is in progress.eventuate.log.replay-batch-size
configuration parameter), replay is suspended until these events have been written to the target database and then resumed again. There's no backpressure mechanism for live event processing yet (but will come in future releases).Result type of the asynchronous read operation.
Result type of the asynchronous write operations.
StatefulProcessor
EventsourcedProcessor