public interface Configurer extends LifecycleOperations
Using DefaultConfigurer.defaultConfiguration()
, you will get a Configurer instance with default components
configured. You will need to register your Aggregates (using configureAggregate(AggregateConfiguration)
and
provide a repository implementation for each of them, or if you wish to use event sourcing, register your aggregates
through configureAggregate(Class)
and configure an Event Store (configureEventStore(Function)
or
configureEmbeddedEventStore(Function)
).
DefaultConfigurer
Modifier and Type | Method and Description |
---|---|
Configuration |
buildConfiguration()
Returns the completely initialized Configuration built using this configurer.
|
<A> Configurer |
configureAggregate(AggregateConfiguration<A> aggregateConfiguration)
Configures an Aggregate in this configuration based on the given
aggregateConfiguration . |
default <A> Configurer |
configureAggregate(Class<A> aggregate)
Configures an Aggregate using default settings.
|
default Configurer |
configureCommandBus(Function<Configuration,CommandBus> commandBusBuilder)
Configures the given Command Bus to use in this configuration.
|
Configurer |
configureCorrelationDataProviders(Function<Configuration,List<CorrelationDataProvider>> correlationDataProviderBuilder)
Configures the CorrelationDataProviders that Message processing components should use to attach correlation data
to outgoing messages.
|
default Configurer |
configureDeadlineManager(Function<Configuration,DeadlineManager> deadlineManagerBuilder)
Registers a
DeadlineManager instance with this Configurer . |
Configurer |
configureEmbeddedEventStore(Function<Configuration,EventStorageEngine> storageEngineBuilder)
Configures an Embedded Event Store which uses the given Event Storage Engine to store its events.
|
default Configurer |
configureEventBus(Function<Configuration,EventBus> eventBusBuilder)
Configures the given Event Bus to use in this configuration.
|
Configurer |
configureEventSerializer(Function<Configuration,Serializer> eventSerializerBuilder)
Configures the given event Serializer to use in this configuration.
|
default Configurer |
configureEventStore(Function<Configuration,EventStore> eventStoreBuilder)
Configures the given Event Store to use in this configuration.
|
default Configurer |
configureLifecyclePhaseTimeout(long timeout,
TimeUnit timeUnit)
Configures the timeout of each lifecycle phase.
|
default Configurer |
configureMessageMonitor(Class<?> componentType,
Function<Configuration,MessageMonitor<Message<?>>> messageMonitorBuilder)
Configures the builder function to create the Message Monitor for the Message processing components in this
configuration that match the given componentType, unless more specific configuration based on both type and name
is available.
|
Configurer |
configureMessageMonitor(Class<?> componentType,
MessageMonitorFactory messageMonitorFactory)
Configures the factory to create the Message Monitor for the Message processing components in this configuration
that match the given componentType, unless more specific configuration based on both type and name is available.
|
default Configurer |
configureMessageMonitor(Class<?> componentType,
String componentName,
Function<Configuration,MessageMonitor<Message<?>>> messageMonitorBuilder)
Configures the builder function to create the Message Monitor for the Message processing components in this
configuration that match the given class and name.
|
Configurer |
configureMessageMonitor(Class<?> componentType,
String componentName,
MessageMonitorFactory messageMonitorFactory)
Configures the factory create the Message Monitor for those Message processing components in this configuration
that match the given class and name.
|
Configurer |
configureMessageMonitor(Function<Configuration,BiFunction<Class<?>,String,MessageMonitor<Message<?>>>> messageMonitorFactoryBuilder)
Configures the Message Monitor to use for the Message processing components in this configuration, unless more
specific configuration based on the component's type, or type and name is available.
|
Configurer |
configureMessageSerializer(Function<Configuration,Serializer> messageSerializerBuilder)
Configures the given event Serializer to use in this configuration.
|
default Configurer |
configureQueryBus(Function<Configuration,QueryBus> queryBusBuilder)
Configures the given Query Bus to use in this configuration.
|
default Configurer |
configureQueryUpdateEmitter(Function<Configuration,QueryUpdateEmitter> queryUpdateEmitterBuilder)
Configures the given Query Update Emitter to use in this configuration.
|
default Configurer |
configureResourceInjector(Function<Configuration,ResourceInjector> resourceInjectorBuilder)
Configures the given Resource Injector to use for Sagas in this configuration.
|
default Configurer |
configureSerializer(Function<Configuration,Serializer> serializerBuilder)
Configures the given Serializer to use in this configuration.
|
default Configurer |
configureSnapshotter(Function<Configuration,Snapshotter> snapshotterBuilder)
Registers a
Snapshotter instance with this Configurer . |
default Configurer |
configureSpanFactory(Function<Configuration,SpanFactory> spanFactory)
Registers a
SpanFactory instance with this Configurer . |
default Configurer |
configureTags(Function<Configuration,TagsConfiguration> tagsBuilder)
Configures the given Tags Configuration to use in this configuration.
|
default Configurer |
configureTransactionManager(Function<Configuration,TransactionManager> transactionManagerBuilder)
Configures the given Transaction Manager to use in this configuration.
|
EventProcessingConfigurer |
eventProcessing()
Retrieve the
EventProcessingConfigurer registered as a module with this Configurer. |
default Configurer |
eventProcessing(Consumer<EventProcessingConfigurer> eventProcessingConfigurer)
Locates the
EventProcessingConfigurer registered as a module with this Configurer and provides it to the
given consumer for configuration. |
default void |
onInitialize(Consumer<Configuration> initHandler)
Register an initialization handler which should be invoked prior to starting this
Configurer . |
Configurer |
registerCommandHandler(Function<Configuration,Object> commandHandlerBuilder)
Registers a command handler bean with this
Configurer . |
default Configurer |
registerCommandHandler(int phase,
Function<Configuration,Object> commandHandlerBuilder)
Deprecated.
in favor of
registerCommandHandler(Function) , since the phase of an annotated
handler should be defined through the StartHandler /ShutdownHandler annotation. |
<C> Configurer |
registerComponent(Class<C> componentType,
Function<Configuration,? extends C> componentBuilder)
Registers a component which should be made available to other components or modules in this Configuration.
|
default Configurer |
registerEventHandler(Function<Configuration,Object> eventHandlerBuilder)
Registers a
Function that builds an Event Handler instance. |
Configurer |
registerEventUpcaster(Function<Configuration,EventUpcaster> upcasterBuilder)
Registers an upcaster to be used to upcast Events to a newer version
|
Configurer |
registerHandlerDefinition(BiFunction<Configuration,Class,HandlerDefinition> handlerDefinitionClass)
Registers the definition of a Handler class.
|
Configurer |
registerMessageHandler(Function<Configuration,Object> messageHandlerBuilder)
Registers a message handler bean with this configuration.
|
Configurer |
registerModule(ModuleConfiguration module)
Registers an Axon module with this configuration.
|
Configurer |
registerQueryHandler(Function<Configuration,Object> queryHandlerBuilder)
Registers a query handler bean with this
Configurer . |
default Configurer |
registerQueryHandler(int phase,
Function<Configuration,Object> queryHandlerBuilder)
Deprecated.
in favor of
registerQueryHandler(Function) , since the phase of an annotated handler
should be defined through the StartHandler /ShutdownHandler annotation. |
default Configuration |
start()
Builds the configuration and starts it immediately.
|
onShutdown, onShutdown, onShutdown, onStart, onStart, onStart
Configurer registerEventUpcaster(@Nonnull Function<Configuration,EventUpcaster> upcasterBuilder)
upcasterBuilder
- The function that returns an EventUpcaster based on the configurationConfigurer configureMessageMonitor(@Nonnull Function<Configuration,BiFunction<Class<?>,String,MessageMonitor<Message<?>>>> messageMonitorFactoryBuilder)
messageMonitorFactoryBuilder
- The MessageMonitor builder functiondefault Configurer configureMessageMonitor(@Nonnull Class<?> componentType, @Nonnull Function<Configuration,MessageMonitor<Message<?>>> messageMonitorBuilder)
A component matches componentType if componentType is assignable from the component's class. If a component matches multiple types, and the types derive from each other, the configuration from the most derived type is used. If the matching types do not derive from each other, the result is unspecified.
For example: in case a monitor is configured for CommandBus
and another monitor is configured for
SimpleCommandBus
), components of type
AsynchronousCommandBus
will use the monitor
configured for the SimpleCommandBus.
A component's name matches componentName if they are identical; i.e. they are compared case sensitively.
componentType
- The declared type of the componentmessageMonitorBuilder
- The builder function to useConfigurer configureMessageMonitor(@Nonnull Class<?> componentType, @Nonnull MessageMonitorFactory messageMonitorFactory)
A component matches componentType if componentType is assignable from the component's class. If a component matches multiple types, and the types derive from each other, the configuration from the most derived type is used. If the matching types do not derive from each other, the result is unspecified.
For example: in case a monitor is configured for CommandBus
and another monitor is configured for
SimpleCommandBus
), components of type
AsynchronousCommandBus
will use the monitor
configured for the SimpleCommandBus.
A component's name matches componentName if they are identical; i.e. they are compared case sensitively.
componentType
- The declared type of the componentmessageMonitorFactory
- The factory to usedefault Configurer configureMessageMonitor(@Nonnull Class<?> componentType, @Nonnull String componentName, @Nonnull Function<Configuration,MessageMonitor<Message<?>>> messageMonitorBuilder)
A component matches componentType if componentType is assignable from the component's class. If a component matches multiple types, and the types derive from each other, the configuration from the most derived type is used. If the matching types do not derive from each other, the result is unspecified.
For example: in case a monitor is configured for CommandBus
and another monitor is configured for
SimpleCommandBus
), components of type
AsynchronousCommandBus
will use the monitor
configured for the SimpleCommandBus.
A component's name matches componentName if they are identical; i.e. they are compared case sensitively.
componentType
- The declared type of the componentcomponentName
- The name of the componentmessageMonitorBuilder
- The builder function to useConfigurer configureMessageMonitor(@Nonnull Class<?> componentType, @Nonnull String componentName, @Nonnull MessageMonitorFactory messageMonitorFactory)
A component matches componentType if componentType is assignable from the component's class. If a component matches multiple types, and the types derive from each other, the configuration from the most derived type is used. If the matching types do not derive from each other, the result is unspecified.
For example: in case a monitor is configured for CommandBus
and another monitor is configured for
SimpleCommandBus
), components of type
AsynchronousCommandBus
will use the monitor
configured for the SimpleCommandBus.
A component's name matches componentName if they are identical; i.e. they are compared case sensitively.
componentType
- The declared type of the componentcomponentName
- The name of the componentmessageMonitorFactory
- The factory to useConfigurer configureCorrelationDataProviders(@Nonnull Function<Configuration,List<CorrelationDataProvider>> correlationDataProviderBuilder)
correlationDataProviderBuilder
- the builder function returning the CorrelationDataProvider listConfigurer registerModule(@Nonnull ModuleConfiguration module)
Typically, modules are registered for Event Handling components or Sagas.
module
- The module to registerSagaConfiguration
<C> Configurer registerComponent(@Nonnull Class<C> componentType, @Nonnull Function<Configuration,? extends C> componentBuilder)
Where possible, it is recommended to use the explicit configure...
and register...
methods.
C
- The type of componentcomponentType
- The declared type of the component, typically an interfacecomponentBuilder
- The builder function of this componentConfigurer registerCommandHandler(@Nonnull Function<Configuration,Object> commandHandlerBuilder)
Configurer
. The bean may be of any type. The actual command
handler methods will be detected based on the annotations present on the bean's methods. Message handling
functions annotated with CommandHandler
will be taken into account.
The builder function receives the Configuration
as input, and is expected to return a fully initialized
instance of the command handler bean.
commandHandlerBuilder
- the builder function of the command handler beanConfigurer
, for chaining purposes@Deprecated default Configurer registerCommandHandler(int phase, @Nonnull Function<Configuration,Object> commandHandlerBuilder)
registerCommandHandler(Function)
, since the phase
of an annotated
handler should be defined through the StartHandler
/ShutdownHandler
annotation.Configurer
. The bean may be of any type. The actual command
handler methods will be detected based on the annotations present on the bean's methods. Message handling
functions annotated with CommandHandler
will be taken into account.
The builder function receives the Configuration
as input, and is expected to return a fully initialized
instance of the command handler bean.
commandHandlerBuilder
- the builder function of the command handler beanphase
- defines a phase in which the command handler builder will be invoked during Configuration.start()
and Configuration.shutdown()
. When starting the
configuration handlers are ordered in ascending, when shutting down the
configuration, descending order is used.Configurer
, for chaining purposesConfigurer registerQueryHandler(@Nonnull Function<Configuration,Object> queryHandlerBuilder)
Configurer
. The bean may be of any type. The actual query
handler methods will be detected based on the annotations present on the bean's methods. Message handling
functions annotated with QueryHandler
will be taken into account.
The builder function receives the Configuration
as input, and is expected to return a fully initialized
instance of the query handler bean.
queryHandlerBuilder
- the builder function of the query handler beanConfigurer
, for chaining purposes@Deprecated default Configurer registerQueryHandler(int phase, @Nonnull Function<Configuration,Object> queryHandlerBuilder)
registerQueryHandler(Function)
, since the phase
of an annotated handler
should be defined through the StartHandler
/ShutdownHandler
annotation.Configurer
. The bean may be of any type. The actual query
handler methods will be detected based on the annotations present on the bean's methods. Message handling
functions annotated with QueryHandler
will be taken into account.
The builder function receives the Configuration
as input, and is expected to return a fully initialized
instance of the query handler bean.
queryHandlerBuilder
- the builder function of the query handler beanphase
- defines a phase in which the query handler builder will be invoked during Configuration.start()
and Configuration.shutdown()
. When starting the
configuration handlers are ordered in ascending, when shutting down the configuration,
descending order is used.Configurer
, for chaining purposesConfigurer registerMessageHandler(@Nonnull Function<Configuration,Object> messageHandlerBuilder)
CommandHandler
, EventHandler
and QueryHandler
will be
taken into account.
The builder function receives the Configuration
as input, and is expected to return a fully initialized
instance of the message handler bean.
messageHandlerBuilder
- the builder function of the message handler beanConfigurer
, for chaining purposesConfigurer configureEmbeddedEventStore(@Nonnull Function<Configuration,EventStorageEngine> storageEngineBuilder)
EventStorageEngine
instance.storageEngineBuilder
- The builder function for the EventStorageEngine
default Configurer configureEventStore(@Nonnull Function<Configuration,EventStore> eventStoreBuilder)
EventStore
instance.eventStoreBuilder
- The builder function for the EventStore
default Configurer configureEventBus(@Nonnull Function<Configuration,EventBus> eventBusBuilder)
EventBus
instance.
Note that this builder should not be used when an Event Store is configured. Since Axon 3, the Event Store will act as Event Bus implementation as well.
eventBusBuilder
- The builder function for the EventBus
default Configurer configureCommandBus(@Nonnull Function<Configuration,CommandBus> commandBusBuilder)
CommandBus
instance.commandBusBuilder
- The builder function for the CommandBus
default Configurer configureQueryBus(@Nonnull Function<Configuration,QueryBus> queryBusBuilder)
QueryBus
instance.queryBusBuilder
- The builder function for the QueryBus
default Configurer configureQueryUpdateEmitter(@Nonnull Function<Configuration,QueryUpdateEmitter> queryUpdateEmitterBuilder)
QueryUpdateEmitter
instance.queryUpdateEmitterBuilder
- The builder function for the QueryUpdateEmitter
default Configurer configureSerializer(@Nonnull Function<Configuration,Serializer> serializerBuilder)
Serializer
instance.serializerBuilder
- The builder function for the Serializer
Configurer configureEventSerializer(@Nonnull Function<Configuration,Serializer> eventSerializerBuilder)
Serializer
instance.
This Serializer is specifically used to serialize EventMessage payload and metadata.eventSerializerBuilder
- The builder function for the Serializer
.Configurer configureMessageSerializer(@Nonnull Function<Configuration,Serializer> messageSerializerBuilder)
Serializer
instance.
This Serializer is specifically used to serialize Message payload and Metadata.messageSerializerBuilder
- The builder function for the Serializer
.default Configurer configureTransactionManager(@Nonnull Function<Configuration,TransactionManager> transactionManagerBuilder)
TransactionManager
instance.transactionManagerBuilder
- The builder function for the TransactionManager
default Configurer configureResourceInjector(@Nonnull Function<Configuration,ResourceInjector> resourceInjectorBuilder)
ResourceInjector
instance.resourceInjectorBuilder
- The builder function for the ResourceInjector
default Configurer configureTags(@Nonnull Function<Configuration,TagsConfiguration> tagsBuilder)
TagsConfiguration
instance.tagsBuilder
- The builder function for the TagsConfiguration
<A> Configurer configureAggregate(@Nonnull AggregateConfiguration<A> aggregateConfiguration)
aggregateConfiguration
. This method
allows for more fine-grained configuration compared to the configureAggregate(Class)
method.A
- The type of aggregate the configuration is foraggregateConfiguration
- The instance describing the configuration of an AggregateAggregateConfigurer
default <A> Configurer configureAggregate(@Nonnull Class<A> aggregate)
configureAggregate(AggregateConfiguration)
must be used to register the aggregate.A
- The type of aggregateaggregate
- The aggregate type to register with the ConfigurationConfigurer registerHandlerDefinition(@Nonnull BiFunction<Configuration,Class,HandlerDefinition> handlerDefinitionClass)
handlerDefinitionClass
- A function providing the definition based on the current Configuration as well
as the class being inspected.default Configurer configureSnapshotter(@Nonnull Function<Configuration,Snapshotter> snapshotterBuilder)
Snapshotter
instance with this Configurer
. Defaults to a AggregateSnapshotter
implementation.snapshotterBuilder
- the builder function for the Snapshotter
default Configurer configureDeadlineManager(@Nonnull Function<Configuration,DeadlineManager> deadlineManagerBuilder)
DeadlineManager
instance with this Configurer
. Defaults to a SimpleDeadlineManager
implementation.deadlineManagerBuilder
- a builder function for the DeadlineManager
default Configurer configureSpanFactory(@Nonnull Function<Configuration,SpanFactory> spanFactory)
SpanFactory
instance with this Configurer
. Defaults to a
NoOpSpanFactory
implementation.spanFactory
- a builder function for the SpanFactory
EventProcessingConfigurer eventProcessing() throws AxonConfigurationException
EventProcessingConfigurer
registered as a module with this Configurer. If there aren't
any, it will create an EventProcessingModule
and register it as a module. If there are multiple,
an AxonConfigurationException
is thrown.AxonConfigurationException
- thrown if there are multiple EventProcessingConfigurer
sdefault Configurer eventProcessing(@Nonnull Consumer<EventProcessingConfigurer> eventProcessingConfigurer) throws AxonConfigurationException
EventProcessingConfigurer
registered as a module with this Configurer and provides it to the
given consumer for configuration. If there aren't any pre-registered instances of
EventProcessingConfigurer
, it will create an EventProcessingModule
and register it as a module.
If there are multiple, an AxonConfigurationException
is thrown.
This method is identical to using eventProcessing()
, except that this variant allows for easier fluent
interfacing.eventProcessingConfigurer
- a consumer to configure theAxonConfigurationException
- thrown if there are multiple EventProcessingConfigurer
sdefault Configurer registerEventHandler(@Nonnull Function<Configuration,Object> eventHandlerBuilder)
Function
that builds an Event Handler instance.eventHandlerBuilder
- a Function
that builds an Event Handler instance.default Configurer configureLifecyclePhaseTimeout(long timeout, TimeUnit timeUnit)
Note that if a lifecycle phase exceeds the configured timeout
and timeUnit
combination, the
Configurer will proceed with the following phase. A phase-skip is marked with a warn logging message, as the
chances are high this causes undesired side effects.
The default lifecycle phase timeout is five seconds.
timeout
- the amount of time to wait for lifecycle phase completiontimeUnit
- the unit in which the timeout
is expressedPhase
,
LifecycleHandler
default void onInitialize(@Nonnull Consumer<Configuration> initHandler)
Configurer
.initHandler
- a Consumer
of the configuration, to be ran upon initialization of the Configuration
Configuration buildConfiguration()
default Configuration start()
Copyright © 2010–2023. All rights reserved.