Class AggregateBasedAxonServerTenantEventStorageEngineFactory

java.lang.Object
io.axoniq.framework.messaging.multitenancy.axonserver.eventsourcing.AggregateBasedAxonServerTenantEventStorageEngineFactory
All Implemented Interfaces:
MultiTenantAwareComponent, TenantEventStorageEngineFactory, DescribableComponent

@Internal public class AggregateBasedAxonServerTenantEventStorageEngineFactory extends Object implements TenantEventStorageEngineFactory, MultiTenantAwareComponent
Axon Server implementation of the TenantEventStorageEngineFactory, building one AggregateBasedAxonServerEventStorageEngine per tenant against that tenant's Axon Server context.

This factory is for tenants backed by Axon Server contexts without Dynamic Consistency Boundary support. The aggregate-based engine is created lazily and cached, and evicted on tenant removal, by a TenantScopedCache this factory holds. Following the tenant lifecycle is delegated to that cache through MultiTenantAwareComponent.

Since:
5.4.0
Author:
Jan Galinski
  • Constructor Details

    • AggregateBasedAxonServerTenantEventStorageEngineFactory

      public AggregateBasedAxonServerTenantEventStorageEngineFactory(AxonServerConnectionManager connectionManager, EventConverter defaultConverter, EventTypeResolver eventTypeResolver, @Nullable TenantComponentProvider<Converter> tenantConverterProvider)
      Constructs an AggregateBasedAxonServerTenantEventStorageEngineFactory building per-tenant aggregate storage engines from the given components.
      Parameters:
      connectionManager - the connection manager providing each tenant's Axon Server connection
      defaultConverter - the converter used when no tenant-specific converter is configured
      eventTypeResolver - the resolver for the event types stored in each tenant's context
      tenantConverterProvider - the optional provider of tenant-specific converters
  • Method Details

    • engineFor

      public EventStorageEngine engineFor(TenantDescriptor tenant)
      Description copied from interface: TenantEventStorageEngineFactory
      Returns the EventStorageEngine of the given tenant.
      Specified by:
      engineFor in interface TenantEventStorageEngineFactory
      Parameters:
      tenant - the tenant to return the event storage engine for
      Returns:
      the tenant's EventStorageEngine
    • registerTenant

      public Registration registerTenant(TenantDescriptor tenantDescriptor)
      Description copied from interface: MultiTenantAwareComponent
      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.

      Specified by:
      registerTenant in interface MultiTenantAwareComponent
      Parameters:
      tenantDescriptor - The TenantDescriptor to register with this component.
      Returns:
      A Registration used to deregister the given tenantDescriptor.
    • registerAndStartTenant

      public Registration registerAndStartTenant(TenantDescriptor tenantDescriptor)
      Description copied from interface: MultiTenantAwareComponent
      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.
      Specified by:
      registerAndStartTenant in interface MultiTenantAwareComponent
      Parameters:
      tenantDescriptor - The TenantDescriptor to register with this component.
      Returns:
      A Registration used to deregister the given tenantDescriptor.
    • describeTo

      public void describeTo(ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.