Class EmbeddedEventStore.Builder
java.lang.Object
org.axonframework.eventhandling.AbstractEventBus.Builder
org.axonframework.eventsourcing.eventstore.AbstractEventStore.Builder
org.axonframework.eventsourcing.eventstore.EmbeddedEventStore.Builder
- Enclosing class:
EmbeddedEventStore
Builder class to instantiate an
EmbeddedEventStore.
The following configurable fields have defaults:
- The
MessageMonitoris defaulted to aNoOpMessageMonitor. - The
EventBusSpanFactoryis defaulted to aDefaultEventBusSpanFactorybacked by aNoOpSpanFactory. - The
cachedEventsis defaulted to10000. - The
fetchDelayis defaulted to1000. - The
cleanupDelayis defaulted to10000. - The
TimeUnitis defaulted toTimeUnit.MILLISECONDS. - The
ThreadFactoryis defaulted toAxonThreadFactorywithThreadGroupEmbeddedEventStore.THREAD_GROUP. - The
optimizeEventConsumptionis defaulted totrue.
EventStorageEngine is a hard requirement and as such should be provided.-
Field Summary
Fields inherited from class org.axonframework.eventsourcing.eventstore.AbstractEventStore.Builder
storageEngine -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aEmbeddedEventStoreas specified through this Builder.cachedEvents(int cachedEvents) Sets the maximum number of events in the cache that is shared between the streams of tracking event processors.cleanupDelay(long cleanupDelay) Sets the delay between two clean ups of lagging event processors.fetchDelay(long fetchDelay) Sets the time to wait before fetching new events from the backing storage engine while tracking after a previous stream was fetched and read.messageMonitor(MessageMonitor<? super EventMessage<?>> messageMonitor) Sets theMessageMonitorto monitor ingestedEventMessages.optimizeEventConsumption(boolean optimizeEventConsumption) Sets whether event consumption should be optimized between Event Stream.spanFactory(EventBusSpanFactory spanFactory) Sets theSpanFactoryimplementation to use for providing tracing capabilities.spanFactory(SpanFactory spanFactory) Sets theSpanFactoryimplementation to use for providing tracing capabilities.storageEngine(EventStorageEngine storageEngine) Sets theEventStorageEngineused to store and load events.threadFactory(ThreadFactory threadFactory) Sets theThreadFactoryused to create threads for consuming, producing and cleaning up.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
storageEngine
Description copied from class:AbstractEventStore.BuilderSets theEventStorageEngineused to store and load events.- Overrides:
storageEnginein classAbstractEventStore.Builder- Parameters:
storageEngine- theEventStorageEngineused to store and load events- Returns:
- the current Builder instance, for fluent interfacing
-
messageMonitor
public EmbeddedEventStore.Builder messageMonitor(@Nonnull MessageMonitor<? super EventMessage<?>> messageMonitor) Description copied from class:AbstractEventBus.Builder- Overrides:
messageMonitorin classAbstractEventStore.Builder- Parameters:
messageMonitor- aMessageMonitorto monitor ingestedEventMessages- Returns:
- the current Builder instance, for fluent interfacing
-
spanFactory
Description copied from class:AbstractEventBus.BuilderSets theSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aNoOpSpanFactoryby default, which provides no tracing capabilities.- Overrides:
spanFactoryin classAbstractEventBus.Builder- Parameters:
spanFactory- TheSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
spanFactory
Description copied from class:AbstractEventBus.BuilderSets theSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aDefaultEventBusSpanFactorybacked by aNoOpSpanFactoryby default, which provides no tracing capabilities.- Overrides:
spanFactoryin classAbstractEventBus.Builder- Parameters:
spanFactory- TheEventBusSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
cachedEvents
Sets the maximum number of events in the cache that is shared between the streams of tracking event processors. Defaults to10000.- Parameters:
cachedEvents- anintspecifying the maximum number of events in the cache that is shared between the streams of tracking event processors- Returns:
- the current Builder instance, for fluent interfacing
-
fetchDelay
Sets the time to wait before fetching new events from the backing storage engine while tracking after a previous stream was fetched and read. Note that this only applies to situations in which no events from the current application have meanwhile been committed. If the current application commits events then those events are fetched without delay.Defaults to
1000. Together with thetimeUnit, this will define the exact fetch delay.- Parameters:
fetchDelay- alongspecifying the time to wait before fetching new events from the backing storage engine while tracking after a previous stream was fetched and read- Returns:
- the current Builder instance, for fluent interfacing
-
cleanupDelay
Sets the delay between two clean ups of lagging event processors. An event processor is lagging behind and removed from the set of processors that track cached events if the oldest event in the cache is newer than the last processed event of the event processor. Once removed the processor will be independently fetching directly from the event storage engine until it has caught up again. Event processors will not notice this change during tracking (i.e. the stream is not closed when an event processor falls behind and is removed).Defaults to
1000. Together with thetimeUnit, this will define the exact clean up delay.- Parameters:
cleanupDelay- alongspecifying the delay between two clean ups of lagging event processors- Returns:
- the current Builder instance, for fluent interfacing
-
timeUnit
- Parameters:
timeUnit- theTimeUnitfor thefetchDelayandcleanupDelay- Returns:
- the current Builder instance, for fluent interfacing
-
threadFactory
Sets theThreadFactoryused to create threads for consuming, producing and cleaning up. Defaults to aAxonThreadFactorywithThreadGroupEmbeddedEventStore.THREAD_GROUP.- Parameters:
threadFactory- aThreadFactoryused to create threads for consuming, producing and cleaning up- Returns:
- the current Builder instance, for fluent interfacing
-
optimizeEventConsumption
Sets whether event consumption should be optimized between Event Stream. If set totrue, distinct Event Consumers will read events from the same stream as soon as they reach the head of the stream. Iffalse, they will stay on a private stream. The latter means more database resources will be used, but no side threads are created to fill the consumer cache nor locking is done on consumer threads. This field can also be configured by providing a system property with keyoptimize-event-consumption. Defaults totrue.- Parameters:
optimizeEventConsumption- abooleandefining whether to optimize event consumption of threads by introducing a Event Cache Production thread tailing the head of the stream for the consumers- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aEmbeddedEventStoreas specified through this Builder.- Returns:
- a
EmbeddedEventStoreas specified through this Builder
-
validate
Validates whether the fields contained in this Builder are set accordingly.- Overrides:
validatein classAbstractEventStore.Builder- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-