Class EmbeddedEventStore

All Implemented Interfaces:
DomainEventSequenceAware, EventBus, EventStore, Lifecycle, MessageDispatchInterceptorSupport<EventMessage<?>>, StreamableMessageSource<TrackedEventMessage<?>>, SubscribableMessageSource<EventMessage<?>>

public class EmbeddedEventStore extends AbstractEventStore implements Lifecycle
Implementation of an EventStore that 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 EmbeddedEventStore.Builder.optimizeEventConsumption(boolean) upon creation. Additionally, this can also be turned off by providing a system property with key optimize-event-consumption.

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.

Since:
3.0
Author:
Rene de Waele