Class MultiTenancyConfigurationDefaults

java.lang.Object
io.axoniq.framework.messaging.multitenancy.configuration.MultiTenancyConfigurationDefaults
All Implemented Interfaces:
ConfigurationEnhancer

@Internal @RegistrationScope(scope=CURRENT) public class MultiTenancyConfigurationDefaults extends Object implements ConfigurationEnhancer
ConfigurationEnhancer registering the default multi-tenancy components:

Contributed through the ServiceLoader, so multi-tenancy is active as soon as the axoniq-multi-tenancy module is on the classpath. Use MultiTenancyUtils.disable(ComponentRegistry) to opt out.

Since:
5.3.0
Author:
Stefan Dragisic, Steven van Beelen, Theo Emanuelsson, Jan Galinski, Laura Devriendt, Jakob Hatzl
  • Field Details

    • ENHANCER_ORDER

      public static final int ENHANCER_ORDER
      The order of this enhancer compared to others.

      Runs early, so the multi-tenancy defaults registered here are in place before other enhancers and user registrations that build on them.

      Anchors the multi-tenancy enhancer block: every other multi-tenancy enhancer expresses its order as this value plus a positive offset, so this is always the first of them to run. Anything disabling multi-tenancy from within another enhancer only has to order itself below this value.

      See Also:
    • TENANT_PROVIDER_PHASE

      public static final int TENANT_PROVIDER_PHASE
      The lifecycle phase in which the TenantProvider starts and shuts down.

      Must start well before Phase.INBOUND_COMMAND_CONNECTOR, the phase at which the multi-tenant command bus connector starts every per-tenant connector it was subscribed with by then. Starting the TenantProvider any later would leave it with no known tenants yet, so the connector would start with zero per-tenant connectors to start.

      Public so that backend-specific enhancers registering a TenantProvider implementation (e.g. AxonServerMultiTenancyConfigurationDefaults) can align their component's start and shutdown phase with this one.

      See Also:
    • TENANT_COMPONENT_SUBSCRIBER_PHASE

      public static final int TENANT_COMPONENT_SUBSCRIBER_PHASE
      The lifecycle phase of the TenantComponentProviderSubscriber. It starts after the TenantProvider, so the tenants replayed on subscription are complete. Shutdown runs in reverse phase order, so the subscriptions are cancelled while the TenantProvider is still running.

      Public so that backend-specific enhancers registering a per-tenant command bus connector (e.g. AxonServerMultiTenancyConfigurationDefaults) can subscribe it to the TenantProvider at the same phase.

      See Also:
    • TENANT_COMPONENT_FACTORY_PHASE

      public static final int TENANT_COMPONENT_FACTORY_PHASE
      The start phase in which the components a tenant-routing component composes from are subscribed to the TenantProvider, one before TENANT_COMPONENT_SUBSCRIBER_PHASE.

      A tenant-routing component builds a tenant's parts through these factories, and announces a tenant only once it holds it. Whatever acts on that announcement therefore reaches the factories, which must already hold the tenant by then. Subscribing them a phase earlier makes that order structural rather than a consequence of the order the components happen to be registered in.

      See Also:
    • TENANT_AWARE_QUERY_BUS_ORDER

      public static final int TENANT_AWARE_QUERY_BUS_ORDER
      The order at which TenantAwareQueryBus decorates the QueryBus.

      Must be higher (applied further outside) than DistributedQueryBusConfigurationEnhancer.DISTRIBUTED_QUERY_BUS_ORDER: the distributed QueryBus does not delegate update emission or completion to its wrapped local segment, it owns the update registry directly, so a lower-order (inner) placement of TenantAwareQueryBus would never observe emit or complete calls at all. Staying below InterceptingQueryBus.DECORATION_ORDER keeps it inside the intercepting layer, whose emitUpdate/completeSubscriptions* overrides pass the filter through unmodified regardless.

      See Also:
  • Constructor Details

    • MultiTenancyConfigurationDefaults

      public MultiTenancyConfigurationDefaults()
  • Method Details

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

      public void enhance(ComponentRegistry componentRegistry)
      Description copied from interface: ConfigurationEnhancer
      Enhances the given registry with, for example, additional components and decorators.
      Specified by:
      enhance in interface ConfigurationEnhancer
      Parameters:
      componentRegistry - The registry instance to enhance.