public class AxonServerQueryBus extends Object implements QueryBus
Constructor and Description |
---|
AxonServerQueryBus(AxonServerConnectionManager axonServerConnectionManager,
AxonServerConfiguration configuration,
QueryUpdateEmitter updateEmitter,
QueryBus localSegment,
Serializer messageSerializer,
Serializer genericSerializer,
QueryPriorityCalculator priorityCalculator)
Creates an instance of the AxonServerQueryBus
|
Modifier and Type | Method and Description |
---|---|
void |
disconnect() |
void |
on(QueryProviderInbound.RequestCase requestCase,
Consumer<QueryProviderInbound> consumer) |
void |
publish(QueryProviderOutbound providerOutbound) |
<Q,R> CompletableFuture<QueryResponseMessage<R>> |
query(QueryMessage<Q,R> queryMessage)
Dispatch the given
query to a single QueryHandler subscribed to the given query 's queryName
and responseType. |
QueryServiceGrpc.QueryServiceStub |
queryServiceStub() |
QueryUpdateEmitter |
queryUpdateEmitter()
Gets the
QueryUpdateEmitter associated with this QueryBus . |
Registration |
registerDispatchInterceptor(MessageDispatchInterceptor<? super QueryMessage<?,?>> dispatchInterceptor)
Register the given DispatchInterceptor.
|
Registration |
registerHandlerInterceptor(MessageHandlerInterceptor<? super QueryMessage<?,?>> interceptor)
Register the given
handlerInterceptor . |
<Q,R> Stream<QueryResponseMessage<R>> |
scatterGather(QueryMessage<Q,R> queryMessage,
long timeout,
TimeUnit timeUnit)
Dispatch the given
query to all QueryHandlers subscribed to the given query 's queryName/responseType. |
<R> Registration |
subscribe(String queryName,
Type responseType,
MessageHandler<? super QueryMessage<?,R>> handler)
Subscribe the given
handler to queries with the given queryName and responseType . |
<Q,I,U> SubscriptionQueryResult<QueryResponseMessage<I>,SubscriptionQueryUpdateMessage<U>> |
subscriptionQuery(SubscriptionQueryMessage<Q,I,U> query,
SubscriptionQueryBackpressure backPressure,
int updateBufferSize)
Dispatch the given
query to a single QueryHandler subscribed to the given query 's
queryName/initialResponseType/updateResponseType. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
subscriptionQuery
public AxonServerQueryBus(AxonServerConnectionManager axonServerConnectionManager, AxonServerConfiguration configuration, QueryUpdateEmitter updateEmitter, QueryBus localSegment, Serializer messageSerializer, Serializer genericSerializer, QueryPriorityCalculator priorityCalculator)
axonServerConnectionManager
- creates connection to AxonServer platformconfiguration
- contains client and component names used to identify the application in
AxonServerupdateEmitter
- emits incremental updates to subscription querieslocalSegment
- handles incoming query requestsmessageSerializer
- serializer/deserializer for payload and metadata of query requests and responsesgenericSerializer
- serializer for communication of other objects than payload and metadatapriorityCalculator
- calculates the request priority based on the content and adds it to the requestpublic <R> Registration subscribe(String queryName, Type responseType, MessageHandler<? super QueryMessage<?,R>> handler)
QueryBus
handler
to queries with the given queryName
and responseType
.
Multiple handlers may subscribe to the same combination of queryName/responseType.public <Q,R> CompletableFuture<QueryResponseMessage<R>> query(QueryMessage<Q,R> queryMessage)
QueryBus
query
to a single QueryHandler subscribed to the given query
's queryName
and responseType. This method returns all values returned by the Query Handler as a Collection. This may or may
not be the exact collection as defined in the Query Handler.
If the Query Handler defines a single return object (i.e. not a collection or array), that object is returned as the sole entry in a singleton collection.
When no handlers are available that can answer the given query
, the returned CompletableFuture will be
completed with a NoHandlerForQueryException
.
public QueryServiceGrpc.QueryServiceStub queryServiceStub()
public <Q,R> Stream<QueryResponseMessage<R>> scatterGather(QueryMessage<Q,R> queryMessage, long timeout, TimeUnit timeUnit)
QueryBus
query
to all QueryHandlers subscribed to the given query
's queryName/responseType.
Returns a stream of results which blocks until all handlers have processed the request or when the timeout occurs.
If no handlers are available to provide a result, or when all available handlers throw an exception while attempting to do so, the returned Stream is empty.
Note that any terminal operation (such as Stream.forEach(Consumer)
) on the Stream may cause it to
block until the timeout
has expired, awaiting additional data to include in the stream.
scatterGather
in interface QueryBus
Q
- the payload type of the queryR
- the response type of the queryqueryMessage
- the querytimeout
- time to wait for resultstimeUnit
- unit for the timeoutpublic Registration registerHandlerInterceptor(MessageHandlerInterceptor<? super QueryMessage<?,?>> interceptor)
MessageHandlerInterceptorSupport
handlerInterceptor
. After registration, the interceptor will be invoked for each
handled Message on the messaging component that it was registered to, prior to invoking the message's handler.registerHandlerInterceptor
in interface MessageHandlerInterceptorSupport<QueryMessage<?,?>>
interceptor
- The interceptor to registerpublic Registration registerDispatchInterceptor(MessageDispatchInterceptor<? super QueryMessage<?,?>> dispatchInterceptor)
MessageDispatchInterceptorSupport
registerDispatchInterceptor
in interface MessageDispatchInterceptorSupport<QueryMessage<?,?>>
dispatchInterceptor
- The interceptor to registerpublic void disconnect()
public void publish(QueryProviderOutbound providerOutbound)
public void on(QueryProviderInbound.RequestCase requestCase, Consumer<QueryProviderInbound> consumer)
public <Q,I,U> SubscriptionQueryResult<QueryResponseMessage<I>,SubscriptionQueryUpdateMessage<U>> subscriptionQuery(SubscriptionQueryMessage<Q,I,U> query, SubscriptionQueryBackpressure backPressure, int updateBufferSize)
QueryBus
query
to a single QueryHandler subscribed to the given query
's
queryName/initialResponseType/updateResponseType. The result is lazily created and there will be no execution of
the query handler before there is a subscription to the initial result. In order not to miss updates, the query
bus will queue all updates which happen after the subscription query is done and once the subscription to the
flux is made, these updates will be emitted.
If there is an error during retrieving or consuming initial result, stream for incremental updates is NOT interrupted.
If there is an error during emitting an update, subscription is cancelled causing further emits not reaching the destination.
Provided backpressure mechanism will be used to deal with fast emitters.
subscriptionQuery
in interface QueryBus
Q
- the payload type of the queryI
- the response type of the queryU
- the incremental response types of the queryquery
- the querybackPressure
- the backpressure mechanism to be used for emitting updatesupdateBufferSize
- the size of buffer which accumulates updates before subscription to the flux
is
madepublic QueryUpdateEmitter queryUpdateEmitter()
QueryBus
QueryUpdateEmitter
associated with this QueryBus
.queryUpdateEmitter
in interface QueryBus
QueryUpdateEmitter
Copyright © 2010–2018. All rights reserved.