Class AxonServerQueryBusConnector
- All Implemented Interfaces:
DescribableComponent,QueryBusConnector
QueryBusConnector that connects to AxonServer to enable
the dispatching and receiving of queries. It manages the registration of handlers, query subscriptions, and
disconnection from the AxonServer query bus.
This class facilitates interaction with AxonServer, handles incoming query requests, manages active subscriptions,
and oversees lifecycle phases related to query dispatching and receiving.- Since:
- 5.0.0
- Author:
- Steven van Beelen, Allard Buijze, Jan Galinski
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.messaging.queryhandling.distributed.QueryBusConnector
QueryBusConnector.Handler, QueryBusConnector.UpdateCallback -
Constructor Summary
ConstructorsConstructorDescriptionAxonServerQueryBusConnector(io.axoniq.axonserver.connector.AxonServerConnection connection, AxonServerConfiguration configuration) Creates a QueryBusConnector implementation that connects to AxonServer for dispatching and receiving queries. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.Disconnect the query bus for receiving queries from Axon Server, by unsubscribing all registered query handlers.voidonIncomingQuery(QueryBusConnector.Handler handler) Registers a handler to process incoming query messages.query(QueryMessage query, ProcessingContext context) Sends the givenqueryto the remote QueryBus.Shutdown the query bus asynchronously for dispatching query to Axon Server.voidstart()Starts the Axon ServerQueryBusConnectorimplementation.subscribe(QualifiedName name) Subscribes this connector to queries matching the givenname.subscriptionQuery(QueryMessage query, ProcessingContext context, int updateBufferSize) Sends the givenqueryto the remote QueryBus.booleanunsubscribe(QualifiedName name) Unsubscribes this connector from queries with the givenname.
-
Constructor Details
-
AxonServerQueryBusConnector
public AxonServerQueryBusConnector(@Nonnull io.axoniq.axonserver.connector.AxonServerConnection connection, @Nonnull AxonServerConfiguration configuration) Creates a QueryBusConnector implementation that connects to AxonServer for dispatching and receiving queries.- Parameters:
connection- The connection to AxonServerconfiguration- The configuration containing local settings for this connector
-
-
Method Details
-
start
public void start()Starts the Axon ServerQueryBusConnectorimplementation. -
subscribe
Description copied from interface:QueryBusConnectorSubscribes this connector to queries matching the givenname.- Specified by:
subscribein interfaceQueryBusConnector- Parameters:
name- TheQualifiedNameof theMessage.type()to subscribe to.- Returns:
- A
CompletableFuturethat completes successfully when this connector subscribed to the givenname.
-
unsubscribe
Description copied from interface:QueryBusConnectorUnsubscribes this connector from queries with the givenname.- Specified by:
unsubscribein interfaceQueryBusConnector- Parameters:
name- TheQualifiedNameof theMessage.type()to unsubscribe from.- Returns:
trueif unsubscribing was successful,falseotherwise.
-
onIncomingQuery
Description copied from interface:QueryBusConnectorRegisters a handler to process incoming query messages.- Specified by:
onIncomingQueryin interfaceQueryBusConnector- Parameters:
handler- The handler responsible for managing incoming queries.
-
query
@Nonnull public MessageStream<QueryResponseMessage> query(@Nonnull QueryMessage query, @Nullable ProcessingContext context) Description copied from interface:QueryBusConnectorSends the givenqueryto the remote QueryBus.- Specified by:
queryin interfaceQueryBusConnector- Parameters:
query- The query to send to the remote QueryBus.context- The context, if available, in which the query is generated- Returns:
- the stream of responses for the query
- See Also:
-
subscriptionQuery
@Nonnull public MessageStream<QueryResponseMessage> subscriptionQuery(@Nonnull QueryMessage query, @Nullable ProcessingContext context, int updateBufferSize) Description copied from interface:QueryBusConnectorSends the givenqueryto the remote QueryBus.- Specified by:
subscriptionQueryin interfaceQueryBusConnector- Parameters:
query- The query to send to the remote QueryBus.context- The context, if available, in which the query is generatedupdateBufferSize- The size of the buffer used to store update for the subscription query.- Returns:
- the stream of responses for the query
- See Also:
-
disconnect
Disconnect the query bus for receiving queries from Axon Server, by unsubscribing all registered query handlers.This shutdown operation is performed in the
Phase.INBOUND_QUERY_CONNECTORphase.- Returns:
- A completable future that resolves once the
AxonServerConnection.queryChannel()has prepared disconnecting.
-
shutdownDispatching
Shutdown the query bus asynchronously for dispatching query to Axon Server.This process will wait for dispatched queries which have not received a response yet. This shutdown operation is performed in the
Phase.OUTBOUND_QUERY_CONNECTORSphase.- Returns:
- A completable future which is resolved once all query dispatching activities are completed.
-
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.
-