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 theDistributedQueryBus.queryQueueCapacity- The initial capacity of the priority queue used for query processing tasks.executorServiceFactory- TheExecutorServiceFactoryconstructing the priority-awareExecutorServicefor theDistributedQueryBus.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 Summary
FieldsModifier and TypeFieldDescriptionstatic final DistributedQueryBusConfigurationA default instance of theDistributedQueryBusConfiguration, setting thequeryThreads()to 10, thequeryQueueCapacity()to 1000, theexecutorServiceFactory()to a priority-awareExecutorServiceFactoryusing the configured number of threads, andpreferLocalQueryHandler()totrue. -
Constructor Summary
ConstructorsConstructorDescriptionDistributedQueryBusConfiguration(int queryThreads, int queryQueueCapacity, ExecutorServiceFactory<DistributedQueryBusConfiguration> executorServiceFactory, boolean preferLocalQueryHandler) Compact constructor validating that the givenqueryThreadsandqueryQueueCapacityare strictly positive. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the value of theexecutorServiceFactoryrecord component.final inthashCode()Returns a hash code value for this object.booleanReturns the value of thepreferLocalQueryHandlerrecord component.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.intReturns the value of thequeryQueueCapacityrecord component.queryQueueCapacity(int queryQueueCapacity) Sets the capacity of the priority queue used for query processing tasks.intReturns the value of thequeryThreadsrecord component.queryThreads(int queryThreads) Sets the number of threads to use for the distributed query bus.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT
A default instance of theDistributedQueryBusConfiguration, setting thequeryThreads()to 10, thequeryQueueCapacity()to 1000, theexecutorServiceFactory()to a priority-awareExecutorServiceFactoryusing the configured number of threads, andpreferLocalQueryHandler()totrue.
-
-
Constructor Details
-
DistributedQueryBusConfiguration
public DistributedQueryBusConfiguration(int queryThreads, int queryQueueCapacity, ExecutorServiceFactory<DistributedQueryBusConfiguration> executorServiceFactory, boolean preferLocalQueryHandler) Compact constructor validating that the givenqueryThreadsandqueryQueueCapacityare strictly positive.
-
-
Method Details
-
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
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
-
queryExecutorService
Creates and returns theExecutorServicefor query processing using the configuredExecutorServiceFactoryand queue.- Returns:
- the
ExecutorServicefor query processing
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
queryThreads
public int queryThreads()Returns the value of thequeryThreadsrecord component.- Returns:
- the value of the
queryThreadsrecord component
-
queryQueueCapacity
public int queryQueueCapacity()Returns the value of thequeryQueueCapacityrecord component.- Returns:
- the value of the
queryQueueCapacityrecord component
-
executorServiceFactory
Returns the value of theexecutorServiceFactoryrecord component.- Returns:
- the value of the
executorServiceFactoryrecord component
-
preferLocalQueryHandler
public boolean preferLocalQueryHandler()Returns the value of thepreferLocalQueryHandlerrecord component.- Returns:
- the value of the
preferLocalQueryHandlerrecord component
-