Record Class DistributedQueryBusConfiguration

java.lang.Object
java.lang.Record
io.axoniq.framework.messaging.queryhandling.distributed.DistributedQueryBusConfiguration
Record Components:
queryThreads - The number of threads used by the DistributedQueryBus.
queryQueueCapacity - The initial capacity of the priority queue used for query processing tasks.
executorServiceFactory - The ExecutorServiceFactory constructing the priority-aware ExecutorService for the DistributedQueryBus.
preferLocalQueryHandler - Whether to use local query handlers directly when available, bypassing remote dispatch.

public record DistributedQueryBusConfiguration(int queryThreads, int queryQueueCapacity, ExecutorServiceFactory<DistributedQueryBusConfiguration> executorServiceFactory, boolean preferLocalQueryHandler) extends Record
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, Allard Buijze
  • Field Details

  • Constructor Details

    • DistributedQueryBusConfiguration

      public DistributedQueryBusConfiguration(int queryThreads, int queryQueueCapacity, ExecutorServiceFactory<DistributedQueryBusConfiguration> executorServiceFactory, boolean preferLocalQueryHandler)
      Compact constructor validating that the given queryThreads and queryQueueCapacity are strictly positive.
  • Method Details

    • queryThreads

      public DistributedQueryBusConfiguration queryThreads(int queryThreads)
      Sets the number of threads to use for the distributed query bus.

      Defaults to 10.

      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
    • queryExecutorService

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

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • queryThreads

      public int queryThreads()
      Returns the value of the queryThreads record component.
      Returns:
      the value of the queryThreads record component
    • queryQueueCapacity

      public int queryQueueCapacity()
      Returns the value of the queryQueueCapacity record component.
      Returns:
      the value of the queryQueueCapacity record component
    • executorServiceFactory

      public ExecutorServiceFactory<DistributedQueryBusConfiguration> executorServiceFactory()
      Returns the value of the executorServiceFactory record component.
      Returns:
      the value of the executorServiceFactory record component
    • preferLocalQueryHandler

      public boolean preferLocalQueryHandler()
      Returns the value of the preferLocalQueryHandler record component.
      Returns:
      the value of the preferLocalQueryHandler record component