public static class AxonServerQueryBus.Builder extends Object
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 AxonServerConnectionManager
, the AxonServerConfiguration
, the local QueryBus
, the QueryUpdateEmitter
, and the message and generic
Serializer
s are hard requirements and as such should be provided.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
AxonServerQueryBus.Builder |
axonServerConnectionManager(AxonServerConnectionManager axonServerConnectionManager)
Sets the
AxonServerConnectionManager used to create connections between this application and an Axon
Server instance. |
AxonServerQueryBus |
build()
Initializes a
AxonServerQueryBus as specified through this Builder. |
protected QuerySerializer |
buildQuerySerializer()
Build a
QuerySerializer using the configured messageSerializer , genericSerializer and
configuration . |
protected SubscriptionMessageSerializer |
buildSubscriptionMessageSerializer()
Build a
SubscriptionMessageSerializer using the configured messageSerializer , genericSerializer and configuration . |
AxonServerQueryBus.Builder |
configuration(AxonServerConfiguration configuration)
Sets the
AxonServerConfiguration used to configure several components within the Axon Server Query
Bus, like setting the client id or the number of query handling threads used. |
AxonServerQueryBus.Builder |
executorServiceBuilder(ExecutorServiceBuilder executorServiceBuilder)
Sets the
ExecutorServiceBuilder which builds an ExecutorService based on a given AxonServerConfiguration and BlockingQueue of Runnable . |
AxonServerQueryBus.Builder |
genericSerializer(Serializer genericSerializer)
Sets the generic
Serializer used to de-/serialize incoming and outgoing query ResponseType implementations. |
AxonServerQueryBus.Builder |
instructionAckSource(InstructionAckSource<QueryProviderOutbound> instructionAckSource)
Sets the instruction ack source used to send instruction acknowledgements.
|
AxonServerQueryBus.Builder |
localSegment(QueryBus localSegment)
Sets the local
QueryBus used to dispatch incoming queries to the local environment. |
AxonServerQueryBus.Builder |
messageSerializer(Serializer messageSerializer)
Sets the message
Serializer used to de-/serialize incoming and outgoing queries and query responses. |
AxonServerQueryBus.Builder |
priorityCalculator(QueryPriorityCalculator priorityCalculator)
Sets the
QueryPriorityCalculator used to deduce the priority of an incoming query among other
queries, to give precedence over high(er) valued queries for example. |
AxonServerQueryBus.Builder |
requestStreamFactory(Function<UpstreamAwareStreamObserver<QueryProviderInbound>,io.grpc.stub.StreamObserver<QueryProviderOutbound>> requestStreamFactory)
Sets the request stream factory that creates a request stream based on upstream.
|
AxonServerQueryBus.Builder |
targetContextResolver(TargetContextResolver<? super QueryMessage<?,?>> targetContextResolver)
Sets the
TargetContextResolver used to resolve the target (bounded) context of an ingested QueryMessage . |
AxonServerQueryBus.Builder |
updateEmitter(QueryUpdateEmitter updateEmitter)
Sets the
QueryUpdateEmitter which can be used to emit updates to queries. |
protected void |
validate()
Validates whether the fields contained in this Builder are set accordingly.
|
public AxonServerQueryBus.Builder axonServerConnectionManager(AxonServerConnectionManager axonServerConnectionManager)
AxonServerConnectionManager
used to create connections between this application and an Axon
Server instance.axonServerConnectionManager
- an AxonServerConnectionManager
used to create connections between
this application and an Axon Server instancepublic AxonServerQueryBus.Builder configuration(AxonServerConfiguration configuration)
AxonServerConfiguration
used to configure several components within the Axon Server Query
Bus, like setting the client id or the number of query handling threads used.configuration
- an AxonServerConfiguration
used to configure several components within the Axon
Server Query Buspublic AxonServerQueryBus.Builder localSegment(QueryBus localSegment)
QueryBus
used to dispatch incoming queries to the local environment.localSegment
- a QueryBus
used to dispatch incoming queries to the local environmentpublic AxonServerQueryBus.Builder updateEmitter(QueryUpdateEmitter updateEmitter)
QueryUpdateEmitter
which can be used to emit updates to queries. Required to honor the
QueryBus.queryUpdateEmitter()
contract.updateEmitter
- a QueryUpdateEmitter
which can be used to emit updates to queriespublic AxonServerQueryBus.Builder messageSerializer(Serializer messageSerializer)
Serializer
used to de-/serialize incoming and outgoing queries and query responses.messageSerializer
- a Serializer
used to de-/serialize incoming and outgoing queries and query
responsespublic AxonServerQueryBus.Builder genericSerializer(Serializer genericSerializer)
Serializer
used to de-/serialize incoming and outgoing query ResponseType
implementations.genericSerializer
- a Serializer
used to de-/serialize incoming and outgoing query ResponseType
implementations.public AxonServerQueryBus.Builder priorityCalculator(QueryPriorityCalculator priorityCalculator)
QueryPriorityCalculator
used to deduce the priority of an incoming query among other
queries, to give precedence over high(er) valued queries for example. Defaults to a QueryPriorityCalculator.defaultQueryPriorityCalculator()
.priorityCalculator
- a QueryPriorityCalculator
used to deduce the priority of an incoming query
among other queriespublic AxonServerQueryBus.Builder targetContextResolver(TargetContextResolver<? super QueryMessage<?,?>> targetContextResolver)
TargetContextResolver
used to resolve the target (bounded) context of an ingested QueryMessage
. Defaults to returning the AxonServerConfiguration.getContext()
on any type of query
message being ingested.targetContextResolver
- a TargetContextResolver
used to resolve the target (bounded) context of
an ingested QueryMessage
public AxonServerQueryBus.Builder executorServiceBuilder(ExecutorServiceBuilder executorServiceBuilder)
ExecutorServiceBuilder
which builds an ExecutorService
based on a given AxonServerConfiguration
and BlockingQueue
of Runnable
. This ExecutorService is used to
process incoming queries with. Defaults to a ThreadPoolExecutor
, using the AxonServerConfiguration.getQueryThreads()
for the pool size, a keep-alive-time of 100ms
, the given
BlockingQueue as the work queue and an AxonThreadFactory
.
Note that it is highly recommended to use the given BlockingQueue if you are to provide you own executorServiceBuilder
, as it ensure the query's priority is taken into consideration. Defaults to ExecutorServiceBuilder.defaultQueryExecutorServiceBuilder()
.executorServiceBuilder
- an ExecutorServiceBuilder
used to build an ExecutorService
based on the AxonServerConfiguration
and a BlockingQueue
public AxonServerQueryBus.Builder requestStreamFactory(Function<UpstreamAwareStreamObserver<QueryProviderInbound>,io.grpc.stub.StreamObserver<QueryProviderOutbound>> requestStreamFactory)
UpstreamAwareStreamObserver.getRequestStream()
.requestStreamFactory
- factory that creates a request stream based on upstreampublic AxonServerQueryBus.Builder instructionAckSource(InstructionAckSource<QueryProviderOutbound> instructionAckSource)
DefaultInstructionAckSource
.instructionAckSource
- used to send instruction acknowledgementspublic AxonServerQueryBus build()
AxonServerQueryBus
as specified through this Builder.AxonServerQueryBus
as specified through this Builderprotected QuerySerializer buildQuerySerializer()
QuerySerializer
using the configured messageSerializer
, genericSerializer
and
configuration
.QuerySerializer
based on the configured messageSerializer
, genericSerializer
and configuration
protected SubscriptionMessageSerializer buildSubscriptionMessageSerializer()
SubscriptionMessageSerializer
using the configured messageSerializer
, genericSerializer
and configuration
.SubscriptionMessageSerializer
based on the configured messageSerializer
, genericSerializer
and configuration
protected void validate() throws AxonConfigurationException
AxonConfigurationException
- if one field is asserted to be incorrect according to the Builder's
specificationsCopyright © 2010–2020. All rights reserved.