Class DeadlineManagerParameterResolverFactoryConfigurationEnhancer
- All Implemented Interfaces:
ConfigurationEnhancer
ConfigurationEnhancer that makes a DeadlineManager handler parameter defer its calls to the
ProcessingContext of the handler.
Axon Framework 4 deferred every deadline call made while a unit of work was active to that unit of work's
prepare-commit phase, so a command that failed after scheduling a deadline never stored it. Axon Framework 5 has no
ambient unit of work, and the command handler of an entity runs in no Scope
that could carry its context. This enhancer registers a
ParameterResolverFactory that resolves a parameter declared as
DeadlineManager to a view of the configured AbstractDeadlineManager, bound to the context of the
handler. Calls made through it are deferred to that context, and its dispatch interceptors receive it, as for a
Saga handler.
The parameter is resolved to the configured component itself when it is declared as an implementation type, when
no DeadlineManager is configured, or when the configured one does not extend
AbstractDeadlineManager, such as the org.axonframework.test.deadline.StubDeadlineManager of the saga
test fixture. A DeadlineManager reached in any other way than as a handler parameter, for example as a field
of a collaborator, is not bound to a context, so its calls outside a Saga handler run immediately. The bound view is
not the configured instance, so a handler that casts the parameter to its implementation or compares it by identity
should declare the implementation type instead, or disable this enhancer.
The enhancer is discovered through the ServiceLoader, so an application gets this behaviour by
having axoniq-legacy on its classpath. An application can opt out with
ComponentRegistry.disableEnhancer(Class):
MessagingConfigurer.create()
.componentRegistry(registry -> registry.disableEnhancer(
DeadlineManagerParameterResolverFactoryConfigurationEnhancer.class
));
- Since:
- 5.4.0
- Author:
- Mateusz Nowak
-
Constructor Details
-
DeadlineManagerParameterResolverFactoryConfigurationEnhancer
public DeadlineManagerParameterResolverFactoryConfigurationEnhancer()
-
-
Method Details
-
enhance
Description copied from interface:ConfigurationEnhancer- Specified by:
enhancein interfaceConfigurationEnhancer- Parameters:
registry- The registry instance to enhance.
-