Class SpringCloudConfigurationEnhancer

java.lang.Object
io.axoniq.framework.springcloud.SpringCloudConfigurationEnhancer
All Implemented Interfaces:
ConfigurationEnhancer

public class SpringCloudConfigurationEnhancer extends Object implements ConfigurationEnhancer
A 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 Details

    • ENHANCER_ORDER

      public static final int ENHANCER_ORDER
      The order() 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

      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.
    • order

      public int order()
      Description copied from interface: ConfigurationEnhancer
      Returns 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 0 when not set.

      Specified by:
      order in interface ConfigurationEnhancer
      Returns:
      The order in which this enhancer should be invoked.