Class AxonServerQueryBus.Builder
java.lang.Object
org.axonframework.axonserver.connector.query.AxonServerQueryBus.Builder
- Enclosing class:
AxonServerQueryBus
Builder class to instantiate an
AxonServerQueryBus.
The QueryPriorityCalculator is defaulted to
QueryPriorityCalculator.defaultQueryPriorityCalculator() and the TargetContextResolver defaults
to a lambda returning the AxonServerConfiguration.getContext() as the context. The
ExecutorServiceBuilder defaults to ExecutorServiceBuilder.defaultQueryExecutorServiceBuilder().
The QueryBusSpanFactory defaults to a DefaultQueryBusSpanFactory backed by a
NoOpSpanFactory. The AxonServerConnectionManager, the AxonServerConfiguration, the local
QueryBus, the QueryUpdateEmitter, and the message and generic Serializers are hard
requirements and as such should be provided.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaxonServerConnectionManager(AxonServerConnectionManager axonServerConnectionManager) Sets theAxonServerConnectionManagerused to create connections between this application and an Axon Server instance.build()Initializes aAxonServerQueryBusas specified through this Builder.protected QuerySerializerBuild aQuerySerializerusing the configuredmessageSerializer,genericSerializerandconfiguration.protected SubscriptionMessageSerializerBuild aSubscriptionMessageSerializerusing the configuredmessageSerializer,genericSerializerandconfiguration.configuration(AxonServerConfiguration configuration) Sets theAxonServerConfigurationused to configure several components within the Axon Server Query Bus, like setting the client id or the number of query handling threads used.defaultContext(String defaultContext) Sets the default context for this event store to connect to.Enables shortcut to localQueryBus.executorServiceBuilder(ExecutorServiceBuilder executorServiceBuilder) Deprecated.genericSerializer(Serializer genericSerializer) Sets the genericSerializerused to de-/serialize incoming and outgoing queryResponseTypeimplementations.instructionAckSource(InstructionAckSource<io.axoniq.axonserver.grpc.query.QueryProviderOutbound> instructionAckSource) Deprecated.in through use of the AxonServer java connectorlocalSegment(QueryBus localSegment) Sets the localQueryBusused to dispatch incoming queries to the local environment.messageSerializer(Serializer messageSerializer) Sets the messageSerializerused to de-/serialize incoming and outgoing queries and query responses.priorityCalculator(QueryPriorityCalculator priorityCalculator) Sets theQueryPriorityCalculatorused to deduce the priority of an incoming query among other queries, to give precedence over high(er) valued queries for example.queryExecutorServiceBuilder(ExecutorServiceBuilder executorServiceBuilder) Sets theExecutorServiceBuilderwhich builds anExecutorServicebased on a givenAxonServerConfigurationandBlockingQueueofRunnable.queryInProgressAwait(Duration queryInProgressAwait) Sets thequery in progress await timeoutused to await the successful termination of queries in progress.queryResponseExecutorServiceBuilder(ExecutorServiceBuilder executorServiceBuilder) Sets theExecutorServiceBuilderwhich builds anExecutorServicebased on a givenAxonServerConfigurationandBlockingQueueofRunnable.requestStreamFactory(Function<UpstreamAwareStreamObserver<io.axoniq.axonserver.grpc.query.QueryProviderInbound>, io.grpc.stub.StreamObserver<io.axoniq.axonserver.grpc.query.QueryProviderOutbound>> requestStreamFactory) Deprecated.in through use of the AxonServer java connectorspanFactory(QueryBusSpanFactory spanFactory) Sets theQueryBusSpanFactoryimplementation to use for providing tracing capabilities.spanFactory(SpanFactory spanFactory) Deprecated.UsespanFactory(QueryBusSpanFactory)instead as it provides more configurability.targetContextResolver(TargetContextResolver<? super QueryMessage<?, ?>> targetContextResolver) Sets theTargetContextResolverused to resolve the target (bounded) context of an ingestedQueryMessage.updateEmitter(QueryUpdateEmitter updateEmitter) Sets theQueryUpdateEmitterwhich can be used to emit updates to queries.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
axonServerConnectionManager
public AxonServerQueryBus.Builder axonServerConnectionManager(AxonServerConnectionManager axonServerConnectionManager) Sets theAxonServerConnectionManagerused to create connections between this application and an Axon Server instance.- Parameters:
axonServerConnectionManager- anAxonServerConnectionManagerused to create connections between this application and an Axon Server instance- Returns:
- the current Builder instance, for fluent interfacing
-
configuration
Sets theAxonServerConfigurationused to configure several components within the Axon Server Query Bus, like setting the client id or the number of query handling threads used.- Parameters:
configuration- anAxonServerConfigurationused to configure several components within the Axon Server Query Bus- Returns:
- the current Builder instance, for fluent interfacing
-
localSegment
Sets the localQueryBusused to dispatch incoming queries to the local environment.- Parameters:
localSegment- aQueryBusused to dispatch incoming queries to the local environment- Returns:
- the current Builder instance, for fluent interfacing
-
updateEmitter
Sets theQueryUpdateEmitterwhich can be used to emit updates to queries. Required to honor theQueryBus.queryUpdateEmitter()contract.- Parameters:
updateEmitter- aQueryUpdateEmitterwhich can be used to emit updates to queries- Returns:
- the current Builder instance, for fluent interfacing
-
messageSerializer
Sets the messageSerializerused to de-/serialize incoming and outgoing queries and query responses.- Parameters:
messageSerializer- aSerializerused to de-/serialize incoming and outgoing queries and query responses- Returns:
- the current Builder instance, for fluent interfacing
-
genericSerializer
Sets the genericSerializerused to de-/serialize incoming and outgoing queryResponseTypeimplementations.- Parameters:
genericSerializer- aSerializerused to de-/serialize incoming and outgoing queryResponseTypeimplementations.- Returns:
- the current Builder instance, for fluent interfacing
-
priorityCalculator
Sets theQueryPriorityCalculatorused to deduce the priority of an incoming query among other queries, to give precedence over high(er) valued queries for example. Defaults to aQueryPriorityCalculator.defaultQueryPriorityCalculator().- Parameters:
priorityCalculator- aQueryPriorityCalculatorused to deduce the priority of an incoming query among other queries- Returns:
- the current Builder instance, for fluent interfacing
-
targetContextResolver
public AxonServerQueryBus.Builder targetContextResolver(TargetContextResolver<? super QueryMessage<?, ?>> targetContextResolver) Sets theTargetContextResolverused to resolve the target (bounded) context of an ingestedQueryMessage. Defaults to returning theAxonServerConfiguration.getContext()on any type of query message being ingested.- Parameters:
targetContextResolver- aTargetContextResolverused to resolve the target (bounded) context of an ingestedQueryMessage- Returns:
- the current Builder instance, for fluent interfacing
-
executorServiceBuilder
@Deprecated public AxonServerQueryBus.Builder executorServiceBuilder(ExecutorServiceBuilder executorServiceBuilder) Deprecated.in favor of using thequeryExecutorServiceBuilder(ExecutorServiceBuilder)methodSets theExecutorServiceBuilderwhich builds anExecutorServicebased on a givenAxonServerConfigurationandBlockingQueueofRunnable. This ExecutorService is used to process incoming queries with. Defaults to aThreadPoolExecutor, using theAxonServerConfiguration.getQueryThreads()for the pool size, the given BlockingQueue as the work queue, and anAxonThreadFactory. Note that it is highly recommended to use the given BlockingQueue if you are to provide you ownexecutorServiceBuilder, as it ensures the query's priority is taken into consideration. Defaults toExecutorServiceBuilder.defaultQueryExecutorServiceBuilder().- Parameters:
executorServiceBuilder- anExecutorServiceBuilderused to build anExecutorServicebased on theAxonServerConfigurationand aBlockingQueue- Returns:
- the current Builder instance, for fluent interfacing
-
queryExecutorServiceBuilder
public AxonServerQueryBus.Builder queryExecutorServiceBuilder(ExecutorServiceBuilder executorServiceBuilder) Sets theExecutorServiceBuilderwhich builds anExecutorServicebased on a givenAxonServerConfigurationandBlockingQueueofRunnable. This ExecutorService is used to process incoming queries with. Defaults to aThreadPoolExecutor, using theAxonServerConfiguration.getQueryThreads()for the pool size, the given BlockingQueue as the work queue, and anAxonThreadFactory. Note that it is highly recommended to use the given BlockingQueue if you are to provide you ownexecutorServiceBuilder, as it ensures the query's priority is taken into consideration. Defaults toExecutorServiceBuilder.defaultQueryResponseExecutorServiceBuilder().- Parameters:
executorServiceBuilder- anExecutorServiceBuilderused to build anExecutorServicebased on theAxonServerConfigurationand aBlockingQueue- Returns:
- the current Builder instance, for fluent interfacing
-
queryResponseExecutorServiceBuilder
public AxonServerQueryBus.Builder queryResponseExecutorServiceBuilder(ExecutorServiceBuilder executorServiceBuilder) Sets theExecutorServiceBuilderwhich builds anExecutorServicebased on a givenAxonServerConfigurationandBlockingQueueofRunnable. This ExecutorService is used to process incoming query responses with. Defaults to aThreadPoolExecutor, using theAxonServerConfiguration.getQueryResponseThreads()for the pool size, the given BlockingQueue as the work queue, and anAxonThreadFactory. Note that it is highly recommended to use the given BlockingQueue if you are to provide you ownexecutorServiceBuilder, as it ensures the query's priority is taken into consideration. Defaults toExecutorServiceBuilder.defaultQueryExecutorServiceBuilder().- Parameters:
executorServiceBuilder- anExecutorServiceBuilderused to build anExecutorServicebased on theAxonServerConfigurationand aBlockingQueue- Returns:
- the current Builder instance, for fluent interfacing
-
requestStreamFactory
@Deprecated public AxonServerQueryBus.Builder requestStreamFactory(Function<UpstreamAwareStreamObserver<io.axoniq.axonserver.grpc.query.QueryProviderInbound>, io.grpc.stub.StreamObserver<io.axoniq.axonserver.grpc.query.QueryProviderOutbound>> requestStreamFactory) Deprecated.in through use of the AxonServer java connectorSets the request stream factory that creates a request stream based on upstream. Defaults toUpstreamAwareStreamObserver.getRequestStream().- Parameters:
requestStreamFactory- factory that creates a request stream based on upstream- Returns:
- the current Builder instance, for fluent interfacing
-
instructionAckSource
@Deprecated public AxonServerQueryBus.Builder instructionAckSource(InstructionAckSource<io.axoniq.axonserver.grpc.query.QueryProviderOutbound> instructionAckSource) Deprecated.in through use of the AxonServer java connectorSets the instruction ack source used to send instruction acknowledgements. Defaults toDefaultInstructionAckSource.- Parameters:
instructionAckSource- used to send instruction acknowledgements- Returns:
- the current Builder instance, for fluent interfacing
-
defaultContext
Sets the default context for this event store to connect to.- Parameters:
defaultContext- for this bus to connect to.- Returns:
- the current Builder instance, for fluent interfacing
-
spanFactory
Deprecated.UsespanFactory(QueryBusSpanFactory)instead as it provides more configurability.Sets theSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aNoOpSpanFactoryby default, which provides no tracing capabilities.- Parameters:
spanFactory- TheSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
spanFactory
Sets theQueryBusSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aDefaultQueryBusSpanFactorybacked by aNoOpSpanFactoryby default, which provides no tracing capabilities.- Parameters:
spanFactory- TheQueryBusSpanFactoryimplementation.- Returns:
- The current Builder instance, for fluent interfacing.
-
enabledLocalSegmentShortCut
Enables shortcut to localQueryBus. If query handlers are registered in the local environment they will be invoked directly instead of sending request to axon server.- Returns:
- the current Builder instance, for fluent interfacing
-
queryInProgressAwait
Sets thequery in progress await timeoutused to await the successful termination of queries in progress. When this timeout is exceeded, the query in progress will be canceled.Defaults to a
Durationof 5 seconds.- Parameters:
queryInProgressAwait- Thequery in progress await timeoutused to await the successful termination of queries in progress- Returns:
- The current Builder instance, for fluent interfacing.
-
build
Initializes aAxonServerQueryBusas specified through this Builder.- Returns:
- a
AxonServerQueryBusas specified through this Builder
-
buildQuerySerializer
Build aQuerySerializerusing the configuredmessageSerializer,genericSerializerandconfiguration.- Returns:
- a
QuerySerializerbased on the configuredmessageSerializer,genericSerializerandconfiguration
-
buildSubscriptionMessageSerializer
Build aSubscriptionMessageSerializerusing the configuredmessageSerializer,genericSerializerandconfiguration.- Returns:
- a
SubscriptionMessageSerializerbased on the configuredmessageSerializer,genericSerializerandconfiguration
-
validate
Validates whether the fields contained in this Builder are set accordingly.- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-
queryExecutorServiceBuilder(ExecutorServiceBuilder)method