Class SpringCloudConfigurationEnhancer
- All Implemented Interfaces:
ConfigurationEnhancer
ConfigurationEnhancer, auto-loadable by the ApplicationConfigurer, registering the
SpringCloudCommandBusConnector as the CommandBusConnector to distribute commands with, and the
SpringCloudQueryBusConnector as the QueryBusConnector to distribute queries with.
Registering a connector is all that is needed to distribute messages: the framework's own
DistributedCommandBusConfigurationEnhancer and DistributedQueryBusConfigurationEnhancer decorate
whatever CommandBus and QueryBus are configured into their distributed counterparts as soon as a
connector is present. No bus needs to be constructed here.
This enhancer does nothing unless a SpringCloudMemberDiscovery is present, which the Spring Boot
autoconfiguration provides once a Spring Cloud DiscoveryClient is on hand. The two connectors are registered
independently, so a configuration already carrying one of them still gains the other.
Distributing messages through Spring Cloud and through Axon Server are alternatives, not layers: an application uses
one or the other. This enhancer does not attempt to diagnose an application that configures both, because it cannot
tell the two cases apart — enhancers are invoked again for every nested registry, at which point the connector this
one registered is itself visible in the enclosing scope. It therefore adds a connector only when none is configured
yet, and its order places it after the enhancers that register the other connectors, so that
an explicitly configured connector wins. Choosing between them is a matter of configuration:
axon.axonserver.enabled=false distributes messages through Spring Cloud, and
axon.springcloud.enabled=false distributes them through Axon Server.
- Since:
- 5.4.0
- Author:
- Allard Buijze
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidenhance(ComponentRegistry registry) intorder()Returns the relative order this enhancer should be invoked in, compared to other instances.
-
Field Details
-
ENHANCER_ORDER
public static final int ENHANCER_ORDERTheorder()of this enhancer. Positioned after the Axon Server enhancer (Integer.MIN_VALUE + 10) and the PostgreSQL enhancer (Integer.MIN_VALUE + 20), so that a connector either of those registered is already visible when this enhancer decides whether to step aside.- See Also:
-
-
Constructor Details
-
SpringCloudConfigurationEnhancer
public SpringCloudConfigurationEnhancer()
-
-
Method Details
-
enhance
Description copied from interface:ConfigurationEnhancer- Specified by:
enhancein interfaceConfigurationEnhancer- Parameters:
registry- The registry instance to enhance.
-
order
public int order()Description copied from interface:ConfigurationEnhancerReturns the relative order this enhancer should be invoked in, compared to other instances.Use lower (negative) values for enhancers providing sensible defaults, and higher values for enhancers that should be able to override values potentially previously set. Defaults to
0when not set.- Specified by:
orderin interfaceConfigurationEnhancer- Returns:
- The order in which this enhancer should be invoked.
-