Class MultiTenancyAutoConfiguration
Multi-tenancy is active by default: with the axoniq-multi-tenancy module on the classpath, tenants are
discovered from the connected Axon Server contexts and the tenant of each message is resolved automatically. Either
axon.multitenancy.enabled=false or axon.axonserver.enabled=false switches it off again, the latter
because tenants are Axon Server contexts and there is nothing to serve as one without it.
Application-specific tenant-scoped components need no manual registration: every Spring bean of type
TenantComponentProvider is picked up as an Axon component, subscribed to the tenant lifecycle, and made
resolvable as a message-handler parameter. Declaring such a bean is therefore enough to expose a per-tenant resource
to handlers. Tenant discovery and resolution are customized the same way, by declaring a
TenantResolver or
TenantConnectPredicate bean.
The multi-tenancy enhancers are contributed by the axoniq-multi-tenancy module through the
ServiceLoader, so this autoconfiguration does not register them. They are active out of the
box. It only contributes the ConfigurationEnhancer that switches them off again for either of the two
independent reasons multi-tenancy should not apply, keeping the multi-tenancy core module free of Spring
dependencies.
- Since:
- 5.3.0
- Author:
- Jan Galinski, Laura Devriendt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSwitches multi-tenancy off, for either of the two independent reasons it should not apply: it is explicitly disabled throughaxon.multitenancy.enabled=false, or Axon Server is disabled throughaxon.axonserver.enabled=falseand there are no contexts to serve as tenants.org.springframework.beans.factory.InitializingBeanWarns when multi-tenancy is explicitly enabled while Axon Server is disabled, a combination in which multi-tenancy cannot function and therefore stays inactive, so the misconfiguration is not silent.
-
Constructor Details
-
MultiTenancyAutoConfiguration
public MultiTenancyAutoConfiguration()
-
-
Method Details
-
disableMultiTenancyConfigurationEnhancer
@Bean @Conditional(io.axoniq.framework.springboot.autoconfig.MultiTenancyAutoConfiguration.MultiTenancyDoesNotApply.class) public ConfigurationEnhancer disableMultiTenancyConfigurationEnhancer()Switches multi-tenancy off, for either of the two independent reasons it should not apply: it is explicitly disabled throughaxon.multitenancy.enabled=false, or Axon Server is disabled throughaxon.axonserver.enabled=falseand there are no contexts to serve as tenants.- Returns:
- a configuration enhancer that disables multi-tenancy
-
multiTenancyRequiresAxonServerWarning
@Bean @ConditionalOnProperty(name="axon.multitenancy.enabled",havingValue="true") @ConditionalOnProperty(name="axon.axonserver.enabled",havingValue="false") public org.springframework.beans.factory.InitializingBean multiTenancyRequiresAxonServerWarning()Warns when multi-tenancy is explicitly enabled while Axon Server is disabled, a combination in which multi-tenancy cannot function and therefore stays inactive, so the misconfiguration is not silent.- Returns:
- an
InitializingBeanlogging the misconfiguration on startup
-