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. Deprecated in favor of registering a LocalQueryDispatchPredicate; see preferLocalQueryHandler(boolean)

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 processing thread pool.

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

      @Deprecated(since="5.4.0", forRemoval=true) public DistributedQueryBusConfiguration preferLocalQueryHandler(boolean preferLocalQueryHandler)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Register a LocalQueryDispatchPredicate component instead, which offers the same local shortcut with per-query control. Enabling this flag is equivalent to registering a predicate that always returns true; disabling it is equivalent to registering no predicate. Both settings continue to work by installing a LocalShortcutQueryBusConnector on the QueryBusConnector.
      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

      @Deprecated(since="5.4.0", forRemoval=true) public boolean preferLocalQueryHandler()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Register a LocalQueryDispatchPredicate component instead, which offers the same local shortcut with per-query control. See preferLocalQueryHandler(boolean).
      Indicates whether the distributed query bus should use local query handlers directly when available, bypassing remote dispatch.
      Returns:
      true when local handlers are used directly when available, false when queries always dispatch 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
    • 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