Class PersistentStreamConfigurationEnhancer

java.lang.Object
io.axoniq.framework.springboot.autoconfig.PersistentStreamConfigurationEnhancer
All Implemented Interfaces:
ConfigurationEnhancer, org.springframework.beans.factory.DisposableBean

@Internal @RegistrationScope(scope=CURRENT) public class PersistentStreamConfigurationEnhancer extends Object implements ConfigurationEnhancer, org.springframework.beans.factory.DisposableBean
A ConfigurationEnhancer that registers a SubscribableEventSource component consuming a persistent stream for each entry in AxonServerConfiguration.getPersistentStreams().

Each map key of the AxonServerConfiguration.PersistentStreamSettings becomes the component name (and thus the Spring bean name after being exposed by the SpringComponentRegistry).

The resolved Axon Server stream name defaults to the map key but can be overridden via AxonServerConfiguration.PersistentStreamSettings.getName().

The resulting beans can be referenced by subscribing event processors through axon.eventhandling.processors.<processor-name>.source=<stream-name>.

Example configuration:


 axon:
   axonserver:
     persistent-streams:
       myStream:
         initial-segment-count: 4
         sequencing-policy: SequentialPerAggregatePolicy
         initial-position: TAIL
         batch-size: 10

 axon:
   eventhandling:
     processors:
       MyProjectionGroup:
         source: myStream
 

Actual construction of each source is delegated to a PersistentStreamEventSourceFactory to allow customization if needed. The default factory builds a PersistentStreamEventSource.

The PersistentStreamConfigurationEnhancer also implements DisposableBean and keeps a reference of every ScheduledExecutorService a source asked it for, to shut them down again when the Spring application context closes.

Marked Internal because instances are created by PersistentStreamAutoConfiguration and should not be constructed directly in application code.

Since:
5.2.0
Author:
Jakob Hatzl
See Also:
  • Constructor Details

    • PersistentStreamConfigurationEnhancer

      public PersistentStreamConfigurationEnhancer(org.springframework.beans.factory.ObjectProvider<AxonServerConfiguration> axonServerConfigProvider, PersistentStreamScheduledExecutorBuilder schedulerBuilder, PersistentStreamEventSourceFactory eventSourceFactory)
      Instantiates a PersistentStreamConfigurationEnhancer.
      Parameters:
      axonServerConfigProvider - provider for the Axon Server configuration containing persistent stream settings; resolved lazily to avoid Spring lifecycle ordering issues with SpringComponentRegistry
      schedulerBuilder - the builder used to create a per-stream ScheduledExecutorService
      eventSourceFactory - the eventSourceFactory used to construct each event source
  • Method Details

    • enhance

      public void enhance(ComponentRegistry registry)
      Description copied from interface: ConfigurationEnhancer
      Enhances the given registry with, for example, additional components and decorators.
      Specified by:
      enhance in interface ConfigurationEnhancer
      Parameters:
      registry - The registry instance to enhance.
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean