Class MultiTenancyUtils

java.lang.Object
io.axoniq.framework.messaging.multitenancy.MultiTenancyUtils

public final class MultiTenancyUtils extends Object
Utility class containing reusable functionality for configuring multi-tenancy.

Multi-tenancy is active as soon as the axoniq-multi-tenancy module is on the classpath, because its ConfigurationEnhancers are contributed through the ServiceLoader. disable(ComponentRegistry) is the way to opt out again.

This class lives in the module's base package so that every multi-tenancy ConfigurationEnhancer is a downward dependency and can be referenced as a class literal.

Since:
5.3.0
Author:
Jan Galinski, Jakob Hatzl
  • Method Details

    • disable

      public static void disable(ComponentRegistry componentRegistry)
      Switches multi-tenancy off for the given componentRegistry, leaving it to behave as a single-tenant application.

      Use this to opt out in an application that carries the axoniq-multi-tenancy module transitively but runs single-tenant:

      
       MessagingConfigurer.create()
                          .componentRegistry(MultiTenancyUtils::disable);
       

      Only takes effect while the multi-tenancy enhancers have not run yet. Applying this directly to a ComponentRegistry is therefore always safe, as enhancers run at build time. Applying it from within another ConfigurationEnhancer requires that enhancer to have a lower ConfigurationEnhancer.order() than MultiTenancyConfigurationDefaults.ENHANCER_ORDER.

      Parameters:
      componentRegistry - the ComponentRegistry to disable multi-tenancy in