public class SimpleQueryBus extends Object implements QueryBus
 In case multiple handlers are registered for the same query and response type, the query(QueryMessage)
 method will invoke one of these handlers. Which one is unspecified.
| Constructor and Description | 
|---|
SimpleQueryBus()
Initialize the query bus without monitoring on messages and a  
LoggingQueryInvocationErrorHandler. | 
SimpleQueryBus(MessageMonitor<? super QueryMessage<?,?>> messageMonitor,
              TransactionManager transactionManager,
              QueryInvocationErrorHandler errorHandler)
Initialize the query bus with the given  
messageMonitor and given errorHandler. | 
SimpleQueryBus(TransactionManager transactionManager)
Initialize the query bus using given  
transactionManager to manage transactions around query execution
 with. | 
| Modifier and Type | Method and Description | 
|---|---|
protected Map<String,Collection<org.axonframework.queryhandling.QuerySubscription>> | 
getSubscriptions()
Returns the subscriptions for this query bus. 
 | 
<Q,R> CompletableFuture<QueryResponseMessage<R>> | 
query(QueryMessage<Q,R> query)
Dispatch the given  
query to a single QueryHandler subscribed to the given query's queryName
 and responseType. | 
Registration | 
registerDispatchInterceptor(MessageDispatchInterceptor<QueryMessage<?,?>> interceptor)
Registers an interceptor that intercepts Queries as they are sent. 
 | 
Registration | 
registerHandlerInterceptor(MessageHandlerInterceptor<QueryMessage<?,?>> interceptor)
Registers an interceptor that is used to intercept Queries before they are passed to their
 respective handlers. 
 | 
<Q,R> Stream<QueryResponseMessage<R>> | 
scatterGather(QueryMessage<Q,R> query,
             long timeout,
             TimeUnit unit)
Dispatch the given  
query to all QueryHandlers subscribed to the given query's queryName/responseName. | 
<R> Registration | 
subscribe(String queryName,
         Type responseType,
         MessageHandler<? super QueryMessage<?,R>> handler)
Subscribe the given  
handler to queries with the given queryName and responseName. | 
public SimpleQueryBus()
LoggingQueryInvocationErrorHandler.public SimpleQueryBus(TransactionManager transactionManager)
transactionManager to manage transactions around query execution
 with. No monitoring is applied to messages and a LoggingQueryInvocationErrorHandler is used
 to log errors on handlers during a scatter-gather query.transactionManager - The transaction manager to manage transactions around query execution withpublic SimpleQueryBus(MessageMonitor<? super QueryMessage<?,?>> messageMonitor, TransactionManager transactionManager, QueryInvocationErrorHandler errorHandler)
messageMonitor and given errorHandler.messageMonitor - The message monitor notified for incoming messages and their resulttransactionManager - The transaction manager to manage transactions around query execution witherrorHandler - The error handler to invoke when query handler report an errorpublic <R> Registration subscribe(String queryName, Type responseType, MessageHandler<? super QueryMessage<?,R>> handler)
QueryBushandler to queries with the given queryName and responseName.
 Multiple handlers may subscribe to the same combination of queryName/responseName.public <Q,R> CompletableFuture<QueryResponseMessage<R>> query(QueryMessage<Q,R> query)
QueryBusquery 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 <Q,R> Stream<QueryResponseMessage<R>> scatterGather(QueryMessage<Q,R> query, long timeout, TimeUnit unit)
QueryBusquery to all QueryHandlers subscribed to the given query's queryName/responseName.
 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 QueryBusQ - the payload type of the queryR - the response type of the queryquery - the querytimeout - time to wait for resultsunit - unit for the timeoutprotected Map<String,Collection<org.axonframework.queryhandling.QuerySubscription>> getSubscriptions()
public Registration registerHandlerInterceptor(MessageHandlerInterceptor<QueryMessage<?,?>> interceptor)
interceptor - the interceptor to invoke before passing a Query to the handlerpublic Registration registerDispatchInterceptor(MessageDispatchInterceptor<QueryMessage<?,?>> interceptor)
interceptor - the interceptor to invoke when sending a QueryCopyright © 2010–2018. All rights reserved.