Class EventProcessorConfiguration
- All Implemented Interfaces:
ExtendedConfiguration,ExtensibleConfigurer,DescribableComponent
- Direct Known Subclasses:
PooledStreamingEventProcessorConfiguration,SubscribingEventProcessorConfiguration
EventProcessor implementations.
The ErrorHandler is defaulted to a PropagatingErrorHandler and the UnitOfWorkFactory defaults
to the SimpleUnitOfWorkFactory
- Since:
- 5.0.0
- Author:
- Mateusz Nowak
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ErrorHandlerprotected BiFunction<Class<? extends EventProcessor>, String, List<MessageHandlerInterceptor<? super EventMessage>>> protected List<MessageHandlerInterceptor<? super EventMessage>> protected BiFunction<Class<? extends EventProcessor>, String, MessageMonitor<? super EventMessage>> protected final Stringprotected UnitOfWorkFactory -
Constructor Summary
ConstructorsConstructorDescriptionEventProcessorConfiguration(String processorName, @Nullable Configuration config) Constructs a newEventProcessorConfigurationwith default values and retrieve global default values.Constructs a newEventProcessorConfigurationcopying properties from the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.Returns theErrorHandlerinvoked when anUnitOfWorkthrows an exception during processing.errorHandler(ErrorHandler errorHandler) Sets theErrorHandlerinvoked when anUnitOfWorkthrows an exception during processing.<T extends ConfigurationExtension<?>>
EventProcessorConfigurationRegisters an extension factory for the given type and returnsthisconfigurer for chaining.<T extends ConfigurationExtension<?>>
@Nullable TReturns the extension of the given type, ornullif no extension of that type has been registered.Returns the name of the processor this configuration is for.booleanReturns whether this configuration is for a streaming event processor.Returns theUnitOfWorkFactoryused to createUnitOfWorkinstances for event processing.unitOfWorkFactory(UnitOfWorkFactory unitOfWorkFactory) AUnitOfWorkFactorythat spawnsUnitOfWorkused to process an event batch.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.
-
Field Details
-
processorName
-
errorHandler
-
unitOfWorkFactory
-
interceptors
-
interceptorBuilder
protected BiFunction<Class<? extends EventProcessor>,String, interceptorBuilderList<MessageHandlerInterceptor<? super EventMessage>>> -
monitorBuilder
protected BiFunction<Class<? extends EventProcessor>,String, monitorBuilderMessageMonitor<? super EventMessage>>
-
-
Constructor Details
-
EventProcessorConfiguration
Constructs a newEventProcessorConfigurationwith default values and retrieve global default values.When the given
configisnull, theMessageHandlerInterceptorsandMessageMonitorwill not be retrieved from theHandlerInterceptorRegistryandMessageMonitorRegistryrespectively.- Parameters:
processorName- the name of the processor this configuration is forconfig- the config, used to retrieve global default values, likeMessageHandlerInterceptors, from
-
EventProcessorConfiguration
Constructs a newEventProcessorConfigurationcopying properties from the given configuration.- Parameters:
base- theEventProcessorConfigurationto copy properties from
-
-
Method Details
-
errorHandler
Sets theErrorHandlerinvoked when anUnitOfWorkthrows an exception during processing. Defaults to aPropagatingErrorHandler.- Parameters:
errorHandler- theErrorHandlerinvoked when anUnitOfWorkthrows an exception during processing- Returns:
- The current instance, for fluent interfacing.
-
unitOfWorkFactory
AUnitOfWorkFactorythat spawnsUnitOfWorkused to process an event batch.- Parameters:
unitOfWorkFactory- AUnitOfWorkFactorythat spawnsUnitOfWork.- Returns:
- The current instance, for fluent interfacing.
-
validate
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
Returns the name of the processor this configuration is for.- Returns:
- The processor name.
-
errorHandler
Returns theErrorHandlerinvoked when anUnitOfWorkthrows an exception during processing.- Returns:
- The
ErrorHandlerfor thisEventProcessorimplementation.
-
unitOfWorkFactory
Returns theUnitOfWorkFactoryused to createUnitOfWorkinstances for event processing.- Returns:
- The
UnitOfWorkFactoryfor thisEventProcessorimplementation.
-
streaming
public boolean streaming()Returns whether this configuration is for a streaming event processor.- Returns:
falsefor basic configuration,truefor streaming configurations.
-
extension
Description copied from interface:ExtendedConfigurationReturns the extension of the given type, ornullif 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:
extensionin interfaceExtendedConfiguration- Type Parameters:
T- the extension type- Parameters:
extensionType- the extension class- Returns:
- the extension instance, or
nullif not registered
-
extend
public <T extends ConfigurationExtension<?>> EventProcessorConfiguration extend(Class<T> extensionType, Supplier<T> factory) Description copied from interface:ExtensibleConfigurerRegisters an extension factory for the given type and returnsthisconfigurer 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:
extendin interfaceExtensibleConfigurer- Type Parameters:
T- the extension type- Parameters:
extensionType- the extension classfactory- a supplier that returns a configured extension- Returns:
thisconfigurer, for fluent chaining
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods 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
DescribableComponentimplementation 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 thedescribeTomethod, 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:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-