public class EmbeddedEventStore extends AbstractEventStore
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.
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 |
---|---|
static class |
EmbeddedEventStore.Builder
Builder class to instantiate an
EmbeddedEventStore . |
Modifier | Constructor and Description |
---|---|
protected |
EmbeddedEventStore(EmbeddedEventStore.Builder builder)
Instantiate a
EmbeddedEventStore based on the fields contained in the EmbeddedEventStore.Builder . |
Modifier and Type | Method and Description |
---|---|
protected void |
afterCommit(List<? extends EventMessage<?>> events)
Process given
events after the Unit of Work has been committed. |
static EmbeddedEventStore.Builder |
builder()
Instantiate a Builder to be able to create an
EmbeddedEventStore . |
TrackingEventStream |
openStream(TrackingToken trackingToken)
Open a stream containing all messages since given tracking token.
|
void |
shutDown()
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
subscribe
createTokenSince
protected EmbeddedEventStore(EmbeddedEventStore.Builder builder)
EmbeddedEventStore
based on the fields contained in the EmbeddedEventStore.Builder
.
Will assert that the EventStorageEngine
is not null
, and will throw an
AxonConfigurationException
if it is null
.
builder
- the EmbeddedEventStore.Builder
used to instantiate a EmbeddedEventStore
instancepublic static EmbeddedEventStore.Builder builder()
EmbeddedEventStore
.
The following configurable fields have defaults:
MessageMonitor
is defaulted to a NoOpMessageMonitor
.cachedEvents
is defaulted to 10000
.fetchDelay
is defaulted to 1000
.cleanupDelay
is defaulted to 10000
.TimeUnit
is defaulted to TimeUnit.MILLISECONDS
.ThreadFactory
is defaulted to AxonThreadFactory
with ThreadGroup
THREAD_GROUP
.EventStorageEngine
is a hard requirement and as such should be provided.EmbeddedEventStore
@PreDestroy public void shutDown()
protected void afterCommit(List<? extends EventMessage<?>> events)
AbstractEventBus
events
after the Unit of Work has been committed. The default implementation does
nothing.afterCommit
in class AbstractEventBus
events
- Events to be published by this Event Buspublic TrackingEventStream openStream(TrackingToken trackingToken)
StreamableMessageSource
trackingToken
of null
to
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 null
to open a stream containing all
messagesCopyright © 2010–2018. All rights reserved.