Class DistributedQueryBusConfiguration
java.lang.Object
org.axonframework.messaging.queryhandling.distributed.DistributedQueryBusConfiguration
Configuration for the
DistributedQueryBus.
Can be used to modify non-critical settings of the bus, such as the query and query response thread pools.
- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a defaultDistributedQueryBusConfigurationwith the following settings: Query threads: 10 Query queue capacity: 1000 Prefer local query handler:true -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether local query handlers are used directly when available, bypassing remote dispatch.preferLocalQueryHandler(boolean preferLocalQueryHandler) Configures whether the distributed query bus should use local query handlers directly when available, bypassing remote dispatch.Creates and returns theExecutorServicefor query processing using the configuredExecutorServiceFactoryand queue.queryExecutorService(ExecutorService executorService) Sets theExecutorServiceto use for querying in the distributed query bus.queryQueueCapacity(int queryQueueCapacity) Sets the capacity of the priority queue used for query processing tasks.queryThreads(int queryThreads) Registers an Executor Service that uses a thread pool with the given amount ofqueryThreads.
-
Constructor Details
-
DistributedQueryBusConfiguration
public DistributedQueryBusConfiguration()Constructs a defaultDistributedQueryBusConfigurationwith the following settings:- Query threads: 10
- Query queue capacity: 1000
- Prefer local query handler:
true
-
-
Method Details
-
queryThreads
Registers an Executor Service that uses a thread pool with the given amount ofqueryThreads.Defaults to a pool with 10 threads.
- Parameters:
queryThreads- the number of threads to use for the distributed query bus- Returns:
- the configuration itself, for fluent API usage
-
queryQueueCapacity
Sets the capacity of the priority queue used for query processing tasks.Defaults to 1000.
- Parameters:
queryQueueCapacity- the capacity of the query processing queue- Returns:
- the configuration itself, for fluent API usage
-
queryExecutorService
Sets theExecutorServiceto use for querying in the distributed query bus.Defaults to a fixed thread pool with 10 threads using the priority queue.
- Parameters:
executorService- theExecutorServiceto use for querying in the distributed query bus- Returns:
- the configuration itself, for fluent API usage
-
preferLocalQueryHandler
Configures whether the distributed query bus should use local query handlers directly when available, bypassing remote dispatch.When enabled, queries for which a local handler is registered will be executed locally without going through the
QueryBusConnector, improving performance by avoiding network overhead. Only when no local handler is available will the query be dispatched remotely. This is safe when query handlers are deterministic and consistent across all nodes.Defaults to
true.- Parameters:
preferLocalQueryHandler-trueto use local handlers directly when available,falseto always dispatch through the connector- Returns:
- the updated instance of
DistributedQueryBusConfiguration, allowing for fluent API usage
-
preferLocalQueryHandler
public boolean preferLocalQueryHandler()Indicates whether local query handlers are used directly when available, bypassing remote dispatch.- Returns:
trueif local handlers are used directly when available,falseif all queries are dispatched through the connector
-
queryExecutorService
Creates and returns theExecutorServicefor query processing using the configuredExecutorServiceFactoryand queue.- Returns:
- the
ExecutorServicefor query processing
-