Class EventProcessorConfiguration

java.lang.Object
org.axonframework.messaging.eventhandling.configuration.EventProcessorConfiguration
All Implemented Interfaces:
ExtendedConfiguration, ExtensibleConfigurer, DescribableComponent
Direct Known Subclasses:
PooledStreamingEventProcessorConfiguration, SubscribingEventProcessorConfiguration

public class EventProcessorConfiguration extends Object implements ExtendedConfiguration, ExtensibleConfigurer, DescribableComponent
Configuration class to be used for EventProcessor implementations.

The ErrorHandler is defaulted to a PropagatingErrorHandler and the UnitOfWorkFactory defaults to the SimpleUnitOfWorkFactory

Since:
5.0.0
Author:
Mateusz Nowak
  • Field Details

  • Constructor Details

  • Method Details

    • errorHandler

      public EventProcessorConfiguration errorHandler(ErrorHandler errorHandler)
      Sets the ErrorHandler invoked when an UnitOfWork throws an exception during processing. Defaults to a PropagatingErrorHandler.
      Parameters:
      errorHandler - the ErrorHandler invoked when an UnitOfWork throws an exception during processing
      Returns:
      The current instance, for fluent interfacing.
    • unitOfWorkFactory

      public EventProcessorConfiguration unitOfWorkFactory(UnitOfWorkFactory unitOfWorkFactory)
      A UnitOfWorkFactory that spawns UnitOfWork used to process an event batch.
      Parameters:
      unitOfWorkFactory - A UnitOfWorkFactory that spawns UnitOfWork.
      Returns:
      The current instance, for fluent interfacing.
    • validate

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

      public String processorName()
      Returns the name of the processor this configuration is for.
      Returns:
      The processor name.
    • errorHandler

      public ErrorHandler errorHandler()
      Returns the ErrorHandler invoked when an UnitOfWork throws an exception during processing.
      Returns:
      The ErrorHandler for this EventProcessor implementation.
    • unitOfWorkFactory

      public UnitOfWorkFactory unitOfWorkFactory()
      Returns the UnitOfWorkFactory used to create UnitOfWork instances for event processing.
      Returns:
      The UnitOfWorkFactory for this EventProcessor implementation.
    • streaming

      public boolean streaming()
      Returns whether this configuration is for a streaming event processor.
      Returns:
      false for basic configuration, true for streaming configurations.
    • extension

      public <T extends ConfigurationExtension<?>> @Nullable T extension(Class<T> extensionType)
      Description copied from interface: ExtendedConfiguration
      Returns the extension of the given type, or null if no extension of that type has been registered.

      Returns the instance created by the factory registered via ExtensibleConfigurer.extend(Class, java.util.function.Supplier).

      Specified by:
      extension in interface ExtendedConfiguration
      Type Parameters:
      T - the extension type
      Parameters:
      extensionType - the extension class
      Returns:
      the extension instance, or null if not registered
    • extend

      public <T extends ConfigurationExtension<?>> EventProcessorConfiguration extend(Class<T> extensionType, Supplier<T> factory)
      Description copied from interface: ExtensibleConfigurer
      Registers an extension factory for the given type and returns this configurer for chaining.

      The factory is invoked immediately — the extension is created eagerly, not lazily. If called multiple times for the same type, the new instance always replaces the previous one.

      Example:

      
       config.extend(DeadLetterQueueConfiguration.class, () -> new DeadLetterQueueConfiguration().enabled().factory(myFactory))
             .extend(MetricsExtension.class, () -> new MetricsExtension().enabled());
       
      Specified by:
      extend in interface ExtensibleConfigurer
      Type Parameters:
      T - the extension type
      Parameters:
      extensionType - the extension class
      factory - a supplier that returns a configured extension
      Returns:
      this configurer, for fluent chaining
    • describeTo

      public void describeTo(ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.