Class MultiTenancyConfigurationDefaults
- All Implemented Interfaces:
ConfigurationEnhancer
ConfigurationEnhancer registering the default multi-tenancy components:
- the default
TenantResolver, which resolves the tenant from message metadata, unless a user registered a customTenantResolver - the
TenantRouterthat every tenant-routing component shares to decide the tenant of a message - the
TenantComponentProviderSubscriberto subscribe everyTenantComponentProviderto theTenantProviderat startup - the
RegisterTenantDescriptorHandlerInterceptorwhich takes the resolvedTenantDescriptorfrom the message and stores it in theProcessingContext - the
AttachTenantDescriptorDispatchInterceptorwhich attaches the tenant of the dispatchingProcessingContextonto a dispatched command or query, so it survives a distributed round trip - the
MultiTenantStreamingProcessorRestarterto restart the running streaming event processors when the set of tenants changes - the
TenantAwareQueryBusdecorator, scoping subscription-query update emission and completion to the tenant resolved from theProcessingContext
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe order ofthisenhancer compared to others.static final intThe order at whichTenantAwareQueryBusdecorates theQueryBus.static final intThe start phase in which the components a tenant-routing component composes from are subscribed to theTenantProvider, one beforeTENANT_COMPONENT_SUBSCRIBER_PHASE.static final intThe lifecycle phase of theTenantComponentProviderSubscriber.static final intThe lifecycle phase in which theTenantProviderstarts and shuts down. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidenhance(ComponentRegistry componentRegistry) intorder()Returns the relative order this enhancer should be invoked in, compared to other instances.
-
Field Details
-
ENHANCER_ORDER
public static final int ENHANCER_ORDERThe order ofthisenhancer 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_PHASEThe lifecycle phase in which theTenantProviderstarts 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 theTenantProviderany 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
TenantProviderimplementation (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_PHASEThe lifecycle phase of theTenantComponentProviderSubscriber. It starts after theTenantProvider, so the tenants replayed on subscription are complete. Shutdown runs in reverse phase order, so the subscriptions are cancelled while theTenantProvideris still running.Public so that backend-specific enhancers registering a per-tenant command bus connector (e.g.
AxonServerMultiTenancyConfigurationDefaults) can subscribe it to theTenantProviderat the same phase.- See Also:
-
TENANT_COMPONENT_FACTORY_PHASE
public static final int TENANT_COMPONENT_FACTORY_PHASEThe start phase in which the components a tenant-routing component composes from are subscribed to theTenantProvider, one beforeTENANT_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_ORDERThe order at whichTenantAwareQueryBusdecorates theQueryBus.Must be higher (applied further outside) than
DistributedQueryBusConfigurationEnhancer.DISTRIBUTED_QUERY_BUS_ORDER: the distributedQueryBusdoes not delegate update emission or completion to its wrapped local segment, it owns the update registry directly, so a lower-order (inner) placement ofTenantAwareQueryBuswould never observe emit or complete calls at all. Staying belowInterceptingQueryBus.DECORATION_ORDERkeeps it inside the intercepting layer, whoseemitUpdate/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: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.
-
enhance
Description copied from interface:ConfigurationEnhancer- Specified by:
enhancein interfaceConfigurationEnhancer- Parameters:
componentRegistry- The registry instance to enhance.
-