Class SagaProcessorConfigurer

java.lang.Object
org.axonframework.extension.spring.config.SagaProcessorConfigurer
All Implemented Interfaces:
ConfigurationEnhancer, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

@Internal @RegistrationScope("Copying this enhancer into a module\'s own registry would make it build a fresh set of Saga processor modules for every module it already built, without ever terminating.") public class SagaProcessorConfigurer extends Object implements ConfigurationEnhancer, org.springframework.context.ApplicationContextAware
Assembles the event processors carrying the Axon Framework 4 Sagas discovered in a Spring application context.

Sagas are assembled here rather than through DefaultProcessorModuleFactory, deliberately. Everything Saga support needs -- registering an already assembled Saga manager instead of inspecting a bean for annotated handler methods, deriving a <SagaName>Processor name, and starting a Saga's processor at the head of the stream -- would otherwise have to be threaded as Saga-shaped hooks through the processor factory and the handler discovery that every Axon Framework 5 Spring application relies on. Saga support is a migration aid with a limited life, so it pays for its own assembly instead: this class duplicates a modest amount of DefaultProcessorModuleFactory, and both the duplicate and the rest of Saga support are deleted together with axon-legacy.

The one behavioural consequence is that a Saga and an ordinary event handler can no longer share a processor, as they could under a single @ProcessingGroup in Axon Framework 4. Both pipelines register a module named after the processor, so a collision surfaces at startup as a DuplicateModuleRegistrationException rather than as a silent merge. Several Sagas resolving to the same name do still share one processor.

Processor settings and EventProcessorDefinitions apply to a Saga's processor as they apply to any other, because this class reads the same beans the regular pipeline reads. PooledStreamingEventProcessorModule.Customization beans are the exception: they are deliberately not applied to a Saga's processor. That channel is how cross-cutting Axon Framework 5 infrastructure attaches itself to every processor in an application -- dead-lettering, for one, is enabled by a Customization bean that puts a dead letter queue extension on the processor configuration -- and Axon Framework 4 never dead-lettered a Saga: it never wrapped a Saga manager in its dead-lettering invoker. Silently acquiring behaviour the original never had is the opposite of what a migration aid should do, so a Saga processor opts out of the channel as a whole rather than guessing which customization means well.

Declare a SagaProcessorDefinition bean instead. It is the same capability scoped to Sagas, so no Axon Framework 5 extension can arrive through it, and it neither assigns handlers nor fixes the processor's mode the way an EventProcessorDefinition does. An EventProcessorDefinition naming the processor still applies as well, for an application that wants to configure a Saga's processor the same way it configures every other one.

Registered as a bean by the Saga auto configuration; an application never creates this itself.

Since:
5.4.0
Author:
Mateusz Nowak
  • Constructor Details

    • SagaProcessorConfigurer

      public SagaProcessorConfigurer()
  • 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.
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException