Class SpringCloudAutoConfiguration

java.lang.Object
io.axoniq.framework.springboot.autoconfig.SpringCloudAutoConfiguration

@AutoConfiguration(afterName="io.axoniq.framework.springboot.autoconfig.AxonServerAutoConfiguration") @ConditionalOnClass({SpringCloudCommandBusConnector.class,org.springframework.cloud.client.discovery.DiscoveryClient.class,org.springframework.web.client.RestClient.class}) @EnableConfigurationProperties(SpringCloudProperties.class) public class SpringCloudAutoConfiguration extends Object
Autoconfiguration for the Axoniq Framework Spring Cloud connector.

Registers the collaborators the connector needs, after which the service-loaded SpringCloudConfigurationEnhancer registers the connectors themselves and the framework decorates the configured CommandBus and QueryBus into their distributed counterparts.

These beans live here rather than in the ConfigurationEnhancer because two concerns only work through Spring. SpringCloudMemberDiscovery learns about the cluster from the events Spring Cloud Discovery publishes, which only reach listeners Spring manages, and the two controllers are only mapped as endpoints if Spring MVC knows about them. The rest follows those two.

Activates when a Spring Cloud DiscoveryClient is available — that is, when the application has chosen a discovery implementation of its own — and can be switched off with axon.springcloud.enabled=false. As members reach each other over HTTP through Spring MVC controllers, it also requires a servlet web application; see SpringCloudAutoConfiguration.NonWebApplicationGuard and SpringCloudAutoConfiguration.ReactiveWebApplicationGuard.

No Spring Cloud Registration is needed: members identify themselves through the capabilities endpoint, so the connector works the same with discovery implementations that register the application, such as Eureka, and with those that leave registration to the platform, such as Spring Cloud Kubernetes.

Since:
5.4.0
Author:
Allard Buijze, Steven van Beelen
  • Field Details

    • REST_CLIENT_BEAN

      public static final String REST_CLIENT_BEAN
      The name of the RestClient bean used to send commands to other members of the cluster.
      See Also:
    • QUERY_REST_CLIENT_BEAN

      public static final String QUERY_REST_CLIENT_BEAN
      The name of the RestClient bean used to send queries and subscription queries to other members of the cluster.
      See Also:
    • CAPABILITIES_REST_CLIENT_BEAN

      public static final String CAPABILITIES_REST_CLIENT_BEAN
      The name of the RestClient bean used to ask other instances for their capabilities.
      See Also:
    • DISPATCH_EXECUTOR_BEAN

      public static final String DISPATCH_EXECUTOR_BEAN
      The name of the Executor bean inter-member command and query dispatches run on.
      See Also:
    • QUERY_SCHEDULER_BEAN

      public static final String QUERY_SCHEDULER_BEAN
      The name of the ScheduledExecutorService bean deciding when the deadline of a dispatched query has passed, when a subscription has been silent for too long, and when a subscription being answered is due a keep-alive.
      See Also:
    • KEEP_ALIVE_EXECUTOR_BEAN

      public static final String KEEP_ALIVE_EXECUTOR_BEAN
      The name of the Executor bean the keep-alive writes of subscriptions being answered run on.
      See Also:
    • DISCOVERY_EXECUTOR_BEAN

      public static final String DISCOVERY_EXECUTOR_BEAN
      The name of the ExecutorService bean discovery rounds, and the capability requests within them, run on.
      See Also:
  • Constructor Details

    • SpringCloudAutoConfiguration

      public SpringCloudAutoConfiguration()
  • Method Details

    • disableSpringCloudConfigurationEnhancer

      @Bean @ConditionalOnProperty(name="axon.springcloud.enabled", havingValue="false") public ConfigurationEnhancer disableSpringCloudConfigurationEnhancer()
      Bean creation method for a ConfigurationEnhancer that disables the SpringCloudConfigurationEnhancer when axon.springcloud.enabled is set to false.

      That enhancer is service-loaded, so switching the connector off takes disabling it explicitly rather than withholding a bean. This method sits outside SpringCloudAutoConfiguration.ConnectorConfiguration so that it is still reached when the property has switched the connector's own beans off.

      Returns:
      an enhancer disabling the Spring Cloud configuration enhancer