Class EmbeddedEventStore.Builder

Enclosing class:
EmbeddedEventStore

public static class EmbeddedEventStore.Builder extends AbstractEventStore.Builder
Builder class to instantiate an EmbeddedEventStore.

The following configurable fields have defaults:

The EventStorageEngine is a hard requirement and as such should be provided.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • storageEngine

      public EmbeddedEventStore.Builder storageEngine(EventStorageEngine storageEngine)
      Description copied from class: AbstractEventStore.Builder
      Sets the EventStorageEngine used to store and load events.
      Overrides:
      storageEngine in class AbstractEventStore.Builder
      Parameters:
      storageEngine - the EventStorageEngine used 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
      Sets the MessageMonitor to monitor ingested EventMessages. Defaults to a NoOpMessageMonitor.
      Overrides:
      messageMonitor in class AbstractEventStore.Builder
      Parameters:
      messageMonitor - a MessageMonitor to monitor ingested EventMessages
      Returns:
      the current Builder instance, for fluent interfacing
    • spanFactory

      public EmbeddedEventStore.Builder spanFactory(@Nonnull SpanFactory spanFactory)
      Description copied from class: AbstractEventBus.Builder
      Sets the SpanFactory implementation to use for providing tracing capabilities. Defaults to a NoOpSpanFactory by default, which provides no tracing capabilities.
      Overrides:
      spanFactory in class AbstractEventBus.Builder
      Parameters:
      spanFactory - The SpanFactory implementation
      Returns:
      The current Builder instance, for fluent interfacing.
    • spanFactory

      public EmbeddedEventStore.Builder spanFactory(@Nonnull EventBusSpanFactory spanFactory)
      Description copied from class: AbstractEventBus.Builder
      Sets the SpanFactory implementation to use for providing tracing capabilities. Defaults to a DefaultEventBusSpanFactory backed by a NoOpSpanFactory by default, which provides no tracing capabilities.
      Overrides:
      spanFactory in class AbstractEventBus.Builder
      Parameters:
      spanFactory - The EventBusSpanFactory implementation
      Returns:
      The current Builder instance, for fluent interfacing.
    • cachedEvents

      public EmbeddedEventStore.Builder cachedEvents(int cachedEvents)
      Sets the maximum number of events in the cache that is shared between the streams of tracking event processors. Defaults to 10000.
      Parameters:
      cachedEvents - an int specifying 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

      public EmbeddedEventStore.Builder 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. 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 the timeUnit, this will define the exact fetch delay.

      Parameters:
      fetchDelay - a long specifying 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

      public EmbeddedEventStore.Builder cleanupDelay(long 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 the timeUnit, this will define the exact clean up delay.

      Parameters:
      cleanupDelay - a long specifying the delay between two clean ups of lagging event processors
      Returns:
      the current Builder instance, for fluent interfacing
    • timeUnit

      public EmbeddedEventStore.Builder timeUnit(TimeUnit timeUnit)
      Sets the TimeUnit for the fetchDelay and cleanupDelay. Defaults to TimeUnit.MILLISECONDS.
      Parameters:
      timeUnit - the TimeUnit for the fetchDelay and cleanupDelay
      Returns:
      the current Builder instance, for fluent interfacing
    • threadFactory

      public EmbeddedEventStore.Builder threadFactory(ThreadFactory threadFactory)
      Sets the ThreadFactory used to create threads for consuming, producing and cleaning up. Defaults to a AxonThreadFactory with ThreadGroup EmbeddedEventStore.THREAD_GROUP.
      Parameters:
      threadFactory - a ThreadFactory used to create threads for consuming, producing and cleaning up
      Returns:
      the current Builder instance, for fluent interfacing
    • optimizeEventConsumption

      public EmbeddedEventStore.Builder optimizeEventConsumption(boolean optimizeEventConsumption)
      Sets whether event consumption should be optimized between Event Stream. If set to true, distinct Event Consumers will read events from the same stream as soon as they reach the head of the stream. If false, 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 key optimize-event-consumption. Defaults to true.
      Parameters:
      optimizeEventConsumption - a boolean defining 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

      public EmbeddedEventStore build()
      Initializes a EmbeddedEventStore as specified through this Builder.
      Returns:
      a EmbeddedEventStore as specified through this Builder
    • validate

      protected void validate() throws AxonConfigurationException
      Validates whether the fields contained in this Builder are set accordingly.
      Overrides:
      validate in class AbstractEventStore.Builder
      Throws:
      AxonConfigurationException - if one field is asserted to be incorrect according to the Builder's specifications