Class MultiTenantAxonServerQueryBusConnector
- All Implemented Interfaces:
ConnectorLifecycle,MultiTenantAwareComponent,QueryBusConnector,DescribableComponent
QueryBusConnector.
The connector composes one AxonServerQueryBusConnector per TenantDescriptor, each owning its own
Axon Server connection, query handler subscriptions, and in-flight query tracking. Query subscription state and the
incoming-query handler are replayed onto newly registered tenants.
Internal, because the connector is wired by AxonServerMultiTenancyConfigurationDefaults and
reached through the QueryBusConnector component, never constructed by an application itself.
- Since:
- 5.3.0
- Author:
- Jan Galinski, Jakob Hatzl
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.axoniq.framework.messaging.queryhandling.distributed.QueryBusConnector
QueryBusConnector.Handler, QueryBusConnector.UpdateCallback -
Constructor Summary
ConstructorsConstructorDescriptionMultiTenantAxonServerQueryBusConnector(TenantRouter tenantRouter, AxonServerConnectionManager connectionManager, AxonServerConfiguration configuration, MessageConverter converter) Constructs aMultiTenantAxonServerQueryBusConnector. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.Disconnects the connector.voidonIncomingQuery(QueryBusConnector.Handler handler) Registers a handler that will be called when an incoming query is received.query(QueryMessage query, @Nullable ProcessingContext context) Resolves theconnector for the current tenantand subsequently dispatches the givenqueryto it.registerAndStartTenant(TenantDescriptor tenantDescriptor) Registers the giventenantDescriptoras a known tenant with this multi-tenant aware component.registerTenant(TenantDescriptor tenantDescriptor) Registers the giventenantDescriptoras a known tenant with this multi-tenant aware component.Shuts down the connector gracefully.voidstart()Starts the connector.subscribe(QualifiedName queryName) Subscribes to a query on each tenant-specific connector with the givenqueryName.subscriptionQuery(QueryMessage query, @Nullable ProcessingContext context, int updateBufferSize) Resolves theconnector for the current tenantand subsequently dispatches the given subscriptionqueryto it.booleanunsubscribe(QualifiedName queryName) Unsubscribes from a query with the givenqueryNamefrom each tenant-specific connector.
-
Constructor Details
-
MultiTenantAxonServerQueryBusConnector
public MultiTenantAxonServerQueryBusConnector(TenantRouter tenantRouter, AxonServerConnectionManager connectionManager, AxonServerConfiguration configuration, MessageConverter converter) Constructs aMultiTenantAxonServerQueryBusConnector.- Parameters:
tenantRouter- the resolver used to determine theTenantDescriptora givenQueryMessagebelongs toconnectionManager- the manager used to obtain theAxonServerConnectionfor a given tenantconfiguration- the configuration applied to each per-tenantAxonServerQueryBusConnectorconverter- theMessageConverterused by each per-tenantAxonServerQueryBusConnector
-
-
Method Details
-
start
public void start()Description copied from interface:ConnectorLifecycleStarts the connector.- Specified by:
startin interfaceConnectorLifecycle
-
query
public MessageStream<QueryResponseMessage> query(QueryMessage query, @Nullable ProcessingContext context) Resolves theconnector for the current tenantand subsequently dispatches the givenqueryto it.- Specified by:
queryin interfaceQueryBusConnector- Parameters:
query- the query message to dispatchcontext- the processing context for the query- Returns:
- a
MessageStreamof the responses for the query - See Also:
-
subscriptionQuery
public MessageStream<QueryResponseMessage> subscriptionQuery(QueryMessage query, @Nullable ProcessingContext context, int updateBufferSize) Resolves theconnector for the current tenantand subsequently dispatches the given subscriptionqueryto it.- Specified by:
subscriptionQueryin interfaceQueryBusConnector- Parameters:
query- the subscription query message to dispatchcontext- the processing context for the queryupdateBufferSize- the size of the buffer used to store updates for the subscription query- Returns:
- a
MessageStreamof the responses for the query - See Also:
-
subscribe
Subscribes to a query on each tenant-specific connector with the givenqueryName.The
MultiTenantAxonServerQueryBusConnectorkeeps track of all known subscriptions and replays them on tenants dynamically added at runtime.- Specified by:
subscribein interfaceQueryBusConnector- Parameters:
queryName- theQualifiedNameof the query to subscribe to- Returns:
- a
CompletableFuturethat completes successfully when this connector subscribed to the givenqueryName
-
unsubscribe
Unsubscribes from a query with the givenqueryNamefrom each tenant-specific connector.- Specified by:
unsubscribein interfaceQueryBusConnector- Parameters:
queryName- theQualifiedNameof the query to unsubscribe from- Returns:
trueif the unsubscription was successful,falseotherwise
-
onIncomingQuery
Registers a handler that will be called when an incoming query is received.The handler is registered for each tenant-specific connection to make sure incoming queries from each tenant trigger the handling.
- Specified by:
onIncomingQueryin interfaceQueryBusConnector- Parameters:
handler- theQueryBusConnector.Handlerresponsible for managing incoming queries
-
shutdownDispatching
Description copied from interface:ConnectorLifecycleShuts down the connector gracefully.- Specified by:
shutdownDispatchingin interfaceConnectorLifecycle- Returns:
- a
CompletableFuturethat completes when the connector has been shutdown.
-
disconnect
Description copied from interface:ConnectorLifecycleDisconnects the connector.- Specified by:
disconnectin interfaceConnectorLifecycle- Returns:
- a
CompletableFuturethat completes when the connector has been disconnected.
-
registerTenant
Description copied from interface:MultiTenantAwareComponentRegisters the giventenantDescriptoras a known tenant with this multi-tenant aware component.The caller must retain the returned
Registrationand cancel it when the tenant is removed, since releasing the component's per-tenant resources rides on that cancellation.- Specified by:
registerTenantin interfaceMultiTenantAwareComponent- Parameters:
tenantDescriptor- TheTenantDescriptorto register with this component.- Returns:
- A
Registrationused to deregister the giventenantDescriptor.
-
registerAndStartTenant
Description copied from interface:MultiTenantAwareComponentRegisters the giventenantDescriptoras a known tenant with this multi-tenant aware component. If applicable, this task will construct a tenant segment and start it.- Specified by:
registerAndStartTenantin interfaceMultiTenantAwareComponent- Parameters:
tenantDescriptor- TheTenantDescriptorto register with this component.- Returns:
- A
Registrationused to deregister the giventenantDescriptor.
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods 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
DescribableComponentimplementation 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 thedescribeTomethod, 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:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-