Interface MultiTenantAwareComponent

All Superinterfaces:
DescribableComponent
All Known Subinterfaces:
TenantComponentProvider<T>
All Known Implementing Classes:
AggregateBasedAxonServerTenantEventStorageEngineFactory, AxonServerTenantEventStorageEngineFactory, AxonServerTenantSnapshotStoreFactory, MultiTenantAxonServerCommandBusConnector, MultiTenantAxonServerQueryBusConnector, MultiTenantEventStorageEngine, MultiTenantPersistentStreamEventSource, TenantRoutingSequencedDeadLetterQueueRegistry, TenantScopedCache

public interface MultiTenantAwareComponent extends DescribableComponent
Interface for components that can be registered with a TenantProvider.

Implementations must keep nothing of a tenant whose registration throws: release whatever was allocated for it before rethrowing, since the caller only holds the registrations that were returned. Releasing is best effort: if it fails, attach that failure to the original one with addSuppressed and rethrow the original.

The provider's own undo is best effort as well: a cancel that itself fails can leave a resource behind. The provider logs it and attaches it to the original failure as suppressed.

A returned registration may be cancelled right after it was returned, when another component fails to register the same tenant and the tenant provider rolls the registration back. Implementers must therefore expect that a tenant they started is withdrawn again. In the window before the rollback, a component that is already live may handle a command (its events stay) or open a subscription query (the rollback ends it). At-least-once handling accepts this.

Since:
4.6.0
Author:
Stefan Dragisic
  • Method Details

    • registerTenant

      Registration registerTenant(TenantDescriptor tenantDescriptor)
      Registers the given tenantDescriptor as a known tenant with this multi-tenant aware component.

      The caller must retain the returned Registration and cancel it when the tenant is removed, since releasing the component's per-tenant resources rides on that cancellation.

      If this method throws, the failure rule in the interface documentation applies.

      Parameters:
      tenantDescriptor - The TenantDescriptor to register with this component.
      Returns:
      A Registration used to deregister the given tenantDescriptor.
    • registerAndStartTenant

      Registration registerAndStartTenant(TenantDescriptor tenantDescriptor)
      Registers the given tenantDescriptor as a known tenant with this multi-tenant aware component. If applicable, this task will construct a tenant segment and start it.

      If this method throws, the failure rule in the interface documentation applies.

      Parameters:
      tenantDescriptor - The TenantDescriptor to register with this component.
      Returns:
      A Registration used to deregister the given tenantDescriptor.