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 QueryBusSpanFactory
defaults to a DefaultQueryBusSpanFactory
backed by a
NoOpSpanFactory
. 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 |
defaultContext(String defaultContext)
Sets the default context for this event store to connect to.
|
AxonServerQueryBus.Builder |
enabledLocalSegmentShortCut()
Enables shortcut to local
QueryBus . |
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<io.axoniq.axonserver.grpc.query.QueryProviderOutbound> instructionAckSource)
Deprecated.
in through use of the AxonServer
java connector
|
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 |
queryInProgressAwait(Duration queryInProgressAwait)
Sets the
query in progress await timeout used to await the successful termination of queries
in progress. |
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 connector
|
AxonServerQueryBus.Builder |
spanFactory(QueryBusSpanFactory spanFactory)
Sets the
QueryBusSpanFactory implementation to use for providing tracing capabilities. |
AxonServerQueryBus.Builder |
spanFactory(SpanFactory spanFactory)
Deprecated.
Use
spanFactory(QueryBusSpanFactory) instead as it provides more configurability. |
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
@Deprecated public AxonServerQueryBus.Builder requestStreamFactory(Function<UpstreamAwareStreamObserver<io.axoniq.axonserver.grpc.query.QueryProviderInbound>,io.grpc.stub.StreamObserver<io.axoniq.axonserver.grpc.query.QueryProviderOutbound>> requestStreamFactory)
UpstreamAwareStreamObserver.getRequestStream()
.requestStreamFactory
- factory that creates a request stream based on upstream@Deprecated public AxonServerQueryBus.Builder instructionAckSource(InstructionAckSource<io.axoniq.axonserver.grpc.query.QueryProviderOutbound> instructionAckSource)
DefaultInstructionAckSource
.instructionAckSource
- used to send instruction acknowledgementspublic AxonServerQueryBus.Builder defaultContext(String defaultContext)
defaultContext
- for this bus to connect to.@Deprecated public AxonServerQueryBus.Builder spanFactory(@Nonnull SpanFactory spanFactory)
spanFactory(QueryBusSpanFactory)
instead as it provides more configurability.SpanFactory
implementation to use for providing tracing capabilities. Defaults to a
NoOpSpanFactory
by default, which provides no tracing capabilities.spanFactory
- The SpanFactory
implementationpublic AxonServerQueryBus.Builder spanFactory(@Nonnull QueryBusSpanFactory spanFactory)
QueryBusSpanFactory
implementation to use for providing tracing capabilities. Defaults to a
DefaultQueryBusSpanFactory
backed by a NoOpSpanFactory
by default, which provides no tracing
capabilities.spanFactory
- The QueryBusSpanFactory
implementation.public AxonServerQueryBus.Builder enabledLocalSegmentShortCut()
QueryBus
. If query handlers are registered in the local environment they
will be invoked directly instead of sending request to axon server.public AxonServerQueryBus.Builder queryInProgressAwait(@Nonnull Duration queryInProgressAwait)
query in progress await timeout
used to await the successful termination of queries
in progress. When this timeout is exceeded, the query in progress will be canceled.
Defaults to a Duration
of 5 seconds.
queryInProgressAwait
- The query in progress await timeout
used to await the successful
termination of queries in progresspublic 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–2024. All rights reserved.