Java API for actors that implement EventsourcedActor.
Java API for actors that implement EventsourcedProcessor.
Java API for actors that implement EventsourcedProcessor.
AbstractEventsourcedView for a detailed usage of the Java API
Java API for actors that implement StatefulProcessor.
Java API for actors that implement StatefulProcessor.
AbstractEventsourcedView for a detailed usage of the Java API
Java API for actors that implement EventsourcedView.
Java API for actors that implement EventsourcedView.
Actor handlers may be initialized once in the constructor with various set-methods (e.g. setOnCommand, setOnEvent) or by overriding the respective handler (e.g. onCommand(...), onEvent(...)). If a handler is overridden, the behaviour of it's respective set-method will be ignored.
Example:
public class HelloActor extends AbstractEventsourcedView { public HelloActor(final String id, final ActorRef eventLog) { super(id, eventLog); onCommand(ReceiveBuilder .match(String.class, str -> str.equals("Hello"), value -> sender().tell("World", self()) .matchAny(ev -> value -> sender().tell("Please try again", self()) .build()); } public PartialFunction<Object, BoxedUnit> onEvent() { return ReceiveBuilder .matchAny(HelloEvent.class, ev -> handleEvent(ev)) .build(); } }
Java API for actors that implement EventsourcedWriter.
Java API for actors that implement EventsourcedWriter.
AbstractEventsourcedView for a detailed usage of the Java API
Defines an application version in terms of major
version and minor
version.
Provides a context for managing behaviors.
A ReplicationFilter that can be used in combination with com.rbmhtechnology.eventuate.serializer.DurableEventSerializerWithBinaryPayload.
A ReplicationFilter that can be used in combination with com.rbmhtechnology.eventuate.serializer.DurableEventSerializerWithBinaryPayload.
It evaluates to true
if the payload's manifest matches regex
.
Tracks concurrent Versioned values which arise from concurrent updates.
Tracks concurrent Versioned values which arise from concurrent updates.
Versioned value type
Update type
A ConcurrentVersions implementation that shall be used if updates replace current versioned values (= full updates).
A ConcurrentVersions implementation that shall be used if updates replace current
versioned values (= full updates). ConcurrentVersionsList
is an immutable data structure.
A ConcurrentVersions implementation that shall be used if updates are incremental.
A ConcurrentVersions implementation that shall be used if updates are incremental.
ConcurrentVersionsTree
is a mutable data structure. Therefore, it is recommended not
to share instances of ConcurrentVersionsTree
directly but rather the Versioned
sequence returned by ConcurrentVersionsTree#all. Later releases will be based on
an immutable data structure.
Please note: This implementation does not purge old versions at the moment (which shouldn't be a problem if the number of incremental updates to a versioned aggregate is rather small). In later releases, manual and automated purging of old versions will be supported.
A conditional request is a request to an actor in the EventsourcedView
hierarchy whose delivery to the actor's command handler is delayed until
the request's condition
is in the causal past of that actor (i.e.
A conditional request is a request to an actor in the EventsourcedView
hierarchy whose delivery to the actor's command handler is delayed until
the request's condition
is in the causal past of that actor (i.e. if the
condition
is <=
the actor's current version).
Thrown by an actor in the EventsourcedView hierarchy if it receives a ConditionalRequest but does not extends the ConditionalRequests trait.
Must be extended by actors in the EventsourcedView hierarchy if they want to support ConditionalRequest processing.
Supports the reliable delivery of messages to destinations by enabling applications to redeliver messages until they are confirmed by their destinations.
Supports the reliable delivery of messages to destinations by enabling applications to
redeliver messages until they are confirmed by their destinations. The correlation
identifier between a reliable message and its confirmation message is an
application-defined deliveryId
. Reliable messages are delivered by calling deliver
in
an EventsourcedActor's event handler. When the destination replies with a confirmation
message, the event-sourced actor must persist an application-defined confirmation event
together with the deliveryId
using the persistConfirmation method. Until successful
persistence of the confirmation event, delivered messages are tracked as unconfirmed
messages. Unconfirmed messages can be redelivered by calling redeliverUnconfirmed
. This
is usually done within a command handler by processing scheduler messages. Redelivery
occurs automatically when the event-sourced actor successfully recovered after initial
start or a re-start.
Provider API.
Provider API.
Event storage format. Fields localLogId
and localSequenceNr
differ among replicas, all other fields are not changed
during event replication.
Application-defined event.
Id of emitter (EventsourcedActor or EventsourcedProcessor).
Aggregate id of emitter (EventsourcedActor or EventsourcedProcessor). This is also
the default routing destination of this event. If defined, the event is routed to event-
sourced actors, views, writers and processors with a matching aggregateId
. In any case,
the event is routed to event-sourced actors, views, writers and processors with an undefined
aggregateId
.
Aggregate ids of additional, custom routing destinations. If non-empty, the event is
additionally routed to event-sourced actors, views, writers and processors with a
matching aggregateId
.
Wall-clock timestamp, generated by the source of concurrent activity that is identified by processId
.
Vector timestamp, generated by the source of concurrent activity that is identified by processId
.
Id of the causality-tracking source of concurrent activity. This is the id of the local event log that initially wrote the event.
Id of the local event log.
Sequence number in the local event log.
Delivery id chosen by an application that persisted this event with ConfirmedDelivery.persistConfirmation.
Sequence number of the event that caused the emission of this event in an event handler.
Defined if an EventsourcedActor with a PersistOnEvent mixin emitted this event
with persistOnEvent
. Actually superseded by persistOnEventId
, but still
has to be maintained for backwards compatibility. It is required for confirmation
of old com.rbmhtechnology.eventuate.PersistOnEvent.PersistOnEventRequests from
a snapshot that do not have com.rbmhtechnology.eventuate.PersistOnEvent.PersistOnEventRequest.persistOnEventId
set.
event id of the event that caused the emission of this event in an event handler.
Defined if an EventsourcedActor with a PersistOnEvent mixin emitted this event
with persistOnEvent
.
Implemented by protocol messages that contain a DurableEvent sequence.
EndpointFilters computes a ReplicationFilter that shall be applied to a
replication read request that replicates from a source log (defined by
)
to a target log (defined by sourceLogName
).targetLogId
Unique id of a DurableEvent.
Unique id of a DurableEvent.
This is a stable id of an event across all replicated logs.
the id of the event log the initially wrote the event.
the initial sequence number in this log.
An EventsourcedActor
is an EventsourcedView that can also write new events to its event log.
An EventsourcedActor
is an EventsourcedView that can also write new events to its event log.
New events are written with the asynchronous persist and persistN methods. They must only
be used within the onCommand
command handler. After successful persistence, the onEvent
handler
is automatically called with the persisted event(s). The onEvent
handler is the place where actor
state may be updated. The onCommand
handler should not update actor state but only read it e.g.
for command validation. EventsourcedActor
s that want to persist new events within the onEvent
handler should additionally mixin the PersistOnEvent trait and use the
persistOnEvent method.
An EventsourcedWriter that writes processed events to a targetEventLog
.
An EventsourcedWriter that writes processed events to a targetEventLog
. EventsourcedProcessor
is an idempotent writer that guarantees that no duplicates are ever written to the target event log,
also under failure conditions. Hence, applications don't need to take extra care about idempotency.
Processed events are those returned by processEvent
, an application-defined event handler that is
invoked with events from the source eventLog
.
During initialization, a processor reads the processing progress from the target event log. The timeout
for this read operation can be configured with the eventuate.log.read-timeout
parameter for all
event-sourced processors or defined on a per class or instance basis by overriding readTimeout
. The timeout
for write operations to the target log can be configured with the eventuate.log.write-timeout
parameter
for all event-sourced processors or defined on a per class or instance basis by overriding writeTimeout
.
An EventsourcedProcessor
is a stateless processor i.e. in-memory state created from source events can
not be recovered. An application that needs stateful event processing should use StatefulProcessor
instead.
An EventsourcedProcessor
processor writes events with vector timestamps set to source event vector timestamp.
In other words, it does not modify event vector timestamps.
The source event log and the target event log of an EventsourcedProcessor
must be different. Writing
processed events back to the source event log has no effect.
Maintains the current version of an event-sourced component.
Maintains the current version of an event-sourced component. The current version is updated by merging DurableEvent.vectorTimestamps of handled events.
An actor that derives internal state from events stored in an event log.
An actor that derives internal state from events stored in an event log. Events are pushed from
the eventLog
actor to this actor and handled with the onEvent
event handler. An event handler
defines how internal state is updated from events.
An EventsourcedView
can also store snapshots of internal state with its save
method. During
(re-)start the latest snapshot saved by this actor (if any) is passed as argument to the onSnapshot
handler, if the handler is defined at that snapshot. If the onSnapshot
handler is not defined at
that snapshot or is not overridden at all, event replay starts from scratch. Newer events that are
not covered by the snapshot are handled by onEvent
after onSnapshot
returns.
By default, an EventsourcedView
does not define an aggregateId
. In this case, the eventLog
pushes all events to this actor. If it defines an aggregateId
, the eventLog
actor only pushes
those events that contain that aggregateId
value in their routingDestinations
set.
An EventsourcedView
can only consume events from its eventLog
but cannot produce new events.
Commands sent to an EventsourcedView
during recovery are delayed until recovery completes.
Event replay is subject to backpressure. After a configurable number of events
(see eventuate.log.replay-batch-size
configuration parameter), replay is suspended until these
events have been handled by onEvent
and then resumed again. There's no backpressure mechanism
for live event processing yet (but will come in future releases).
An EventsourcedView designed to update external databases from events stored in its event log.
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
asynchronously read
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
calls write
to asynchronously write the prepared batch to the database.An EventsourcedWriter
may also implement an onCommand
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 from
readSuccess
. If full internal state recovery is required instead, readSuccess
should return None
(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.
Can be mixed into EventsourcedActor for writing new events within the onEvent
handler.
Can be mixed into EventsourcedActor for writing new events within the onEvent
handler. New events are
written with the asynchronous persistOnEvent method. In contrast to persist,
one can not prevent command processing from running concurrently to persistOnEvent by setting
stateSync to true
.
A persistOnEvent
operation is reliable and idempotent. Once the event has been successfully written, a repeated
persistOnEvent
call for that event during event replay has no effect. A failed persistOnEvent
operation will
restart the actor by throwing a PersistOnEventException. After restart, failed persistOnEvent
operations
are automatically re-tried.
Thrown to indicate that an asynchronous persisOnEvent
operation failed.
ReplicationEndpoint.recover completes with this exception if recovery fails.
A replication connection descriptor.
A replication connection descriptor.
Host of the remote actor system that runs a ReplicationEndpoint.
Port of the remote actor system that runs a ReplicationEndpoint.
Name of the remote actor system that runs a ReplicationEndpoint.
A replication endpoint connects to other replication endpoints for replicating events.
A replication endpoint connects to other replication endpoints for replicating events. Events are replicated from the connected endpoints to this endpoint. The connected endpoints are replication sources, this endpoint is a replication target. To setup bi-directional replication, the other replication endpoints must additionally setup replication connections to this endpoint.
A replication endpoint manages one or more event logs. Event logs are indexed by name. Events are replicated only between event logs with matching names.
If applicationName
equals that of a replication source, events are only replicated if applicationVersion
is greater than or equal to that of the replication source. This is a simple mechanism to support
incremental version upgrades of replicated applications where each replica can be upgraded individually
without shutting down other replicas. This avoids permanent state divergence during upgrade which may
occur if events are replicated from replicas with higher version to those with lower version. If
applicationName
does not equal that of a replication source, events are always replicated, regardless
of the applicationVersion
value.
Serializable and composable replication filter.
Java API handler that accepts a success and a failure function.
Java API handler that accepts a success and a failure function. Used to asynchronously execute the appropriate function based on the result of an action or calculation.
type of the result object
Provider API.
Provider API.
Snapshot storage format. EventsourcedActors, EventsourcedViews, stateful EventsourcedWriters and EventsourcedProcessors can save snapshots of internal state by calling the (inherited) EventsourcedView#save method.
Application-specific snapshot.
Id of the event-sourced actor, view, stateful writer or processor that saved the snapshot.
Last handled event before the snapshot was saved.
Current vector time when the snapshot was saved.
Sequence number of the last *received* event when the snapshot was saved.
Unconfirmed DeliveryAttempts when the snapshot was saved (can only be non-empty if the actor implements ConfirmedDelivery).
Unconfirmed PersistOnEventRequests when the snapshot was saved (can only be non-empty if the actor implements PersistOnEvent).
Snapshot metadata.
Snapshot metadata.
Id of the EventsourcedActor, EventsourcedView, stateful EventsourcedWriter or EventsourcedProcessor that saves the snapshot.
The highest event sequence number covered by the snapshot.
Thrown to indicate that a stash()
operation was used at an illegal location.
An EventsourcedProcessor that supports stateful event processing.
An EventsourcedProcessor that supports stateful event processing. In-memory state created from source events is recovered during event replay, either starting from scratch or from a previously saved snapshot.
A StatefulProcessor
writes events with vector timestamps set to the processor's current vector time. In
other words, a written event has a potential causal relationship to all past source events.
Implemented by protocol messages whose event sequence can be updated.
Vector time, represented as process id -> logical time map.
A versioned value.
A versioned value.
The value.
Update vector timestamp of the event that caused this version.
Update system timestamp of the event that caused this version.
Creator of the event that caused this version.
Manages concurrent versions of an event-sourced aggregate.
Manages concurrent versions of an event-sourced aggregate.
Aggregate type.
Command type.
Event type.
Aggregate id
Command handler
Event handler
Aggregate.
Java API
Java API for actors that implement EventsourcedActor.
EventsourcedActor
AbstractEventsourcedView for a detailed usage of the Java API