Class DistributedQueryBusConfiguration

java.lang.Object
org.axonframework.messaging.queryhandling.distributed.DistributedQueryBusConfiguration

public final class DistributedQueryBusConfiguration extends Object
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 Details

    • DistributedQueryBusConfiguration

      public DistributedQueryBusConfiguration()
      Constructs a default DistributedQueryBusConfiguration with the following settings:
      • Query threads: 10
      • Query queue capacity: 1000
      • Prefer local query handler: true
  • Method Details

    • queryThreads

      public DistributedQueryBusConfiguration queryThreads(int queryThreads)
      Registers an Executor Service that uses a thread pool with the given amount of queryThreads.

      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

      public DistributedQueryBusConfiguration queryQueueCapacity(int 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

      public DistributedQueryBusConfiguration queryExecutorService(ExecutorService executorService)
      Sets the ExecutorService to use for querying in the distributed query bus.

      Defaults to a fixed thread pool with 10 threads using the priority queue.

      Parameters:
      executorService - the ExecutorService to use for querying in the distributed query bus
      Returns:
      the configuration itself, for fluent API usage
    • preferLocalQueryHandler

      public DistributedQueryBusConfiguration preferLocalQueryHandler(boolean 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 - true to use local handlers directly when available, false to 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:
      true if local handlers are used directly when available, false if all queries are dispatched through the connector
    • queryExecutorService

      public ExecutorService queryExecutorService()
      Creates and returns the ExecutorService for query processing using the configured ExecutorServiceFactory and queue.
      Returns:
      the ExecutorService for query processing