public class EmbeddedEventStore extends AbstractEventStore
EventStorethat stores and fetches events using an
EventStorageEngine. If supported by its storage engine the embedded event store provides event tracking and replaying capabilities.
The event store can be tracked by multiple event processors simultaneously. To prevent that each event processor
needs to read from the storage engine individually the embedded event store contains a cache of the most recent
events. This cache is shared between the streams of various event processors. So, assuming an event processor
processes events fast enough and is not far behind the head of the event log it will not need a private connection to
the underlying data store. The size of the cache (in number of events) is configurable. This 'event consumption
optimization' might in some scenarios not be desirable, as it will spin up additional threads and perform some
locking operations. Hence it is switchable by using the
creation. Additionally, this can also be turned off by providing a system property with key
The embedded event store automatically fetches new events from the store if there is at least one registered tracking event processor present. It will do so after new events are committed to the store, as well as periodically as events may have been committed by other nodes or applications. This periodic fetch delay is configurable.
|Modifier and Type||Class and Description|
Builder class to instantiate an
|Modifier||Constructor and Description|
|Modifier and Type||Method and Description|
Instantiate a Builder to be able to create an
Open a stream containing all messages since given tracking token.
Method to invoke when the application shuts down.
createHeadToken, createTailToken, createTokenAt, handleSnapshotReadingError, lastSequenceNumberFor, prepareCommit, readEvents, readEvents, stagedDomainEventMessages, storageEngine, storeSnapshot
commit, intercept, publish, queuedMessages, registerDispatchInterceptor, subscribe
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
publish, publish, registerDispatchInterceptor
protected EmbeddedEventStore(EmbeddedEventStore.Builder builder)
EmbeddedEventStorebased on the fields contained in the
public static EmbeddedEventStore.Builder builder()
The following configurable fields have defaults:
MessageMonitoris defaulted to a
cachedEventsis defaulted to
fetchDelayis defaulted to
cleanupDelayis defaulted to
TimeUnitis defaulted to
ThreadFactoryis defaulted to
optimizeEventConsumptionis defaulted to
EventStorageEngineis a hard requirement and as such should be provided.
@PreDestroy public void shutDown()
protected void afterCommit(List<? extends EventMessage<?>> events)
eventsafter the Unit of Work has been committed. The default implementation does nothing.
public TrackingEventStream openStream(TrackingToken trackingToken)
nullto open a stream containing all available messages. Note that the returned stream is infinite, so beware of applying terminal operations to the returned stream.
trackingToken- object containing the position in the stream or
nullto open a stream containing all messages
Copyright © 2010–2021. All rights reserved.