public interface QueryBus
QueryMessage.getQueryName()
and
QueryMessage.getResponseType()
on the query bus. There may be multiple handlers for each combination of
queryName/responseName.Modifier and Type | Method and Description |
---|---|
<Q,R> CompletableFuture<R> |
query(QueryMessage<Q,R> query)
Dispatch the given
query to all QueryHandlers subscribed to the given query 's queryName/responseName. |
<Q,R> Stream<R> |
queryAll(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,
Class<R> responseType,
MessageHandler<? super QueryMessage<?,R>> handler)
Subscribe the given
handler to queries with the given queryName and responseName . |
<R> Registration subscribe(String queryName, Class<R> responseType, MessageHandler<? super QueryMessage<?,R>> handler)
handler
to queries with the given queryName
and responseName
.
Multiple handlers may subscribe to the same combination of queryName/responseName.queryName
- the name of the query request to subscriberesponseType
- the type of response the subscribed component answers withhandler
- a handler that implements the query<Q,R> CompletableFuture<R> query(QueryMessage<Q,R> query)
query
to all QueryHandlers subscribed to the given query
's queryName/responseName.
Completes on the first result. It is up to the QueryBus implementor to decide what the definition of first result is.
When no handlers are available that can answer the query, the returned CompletableFuture will be completed with
a NoHandlerForQueryException
.
Q
- the payload type of the queryR
- the response type of the queryquery
- the query<Q,R> Stream<R> queryAll(QueryMessage<Q,R> query, long timeout, TimeUnit unit)
query
to all QueryHandlers subscribed to the given query
's queryName/responseName.
Returns a stream of results which completes if 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.
Q
- the payload type of the queryR
- the response type of the queryquery
- the querytimeout
- time to wait for resultsunit
- unit for the timeoutCopyright © 2010–2017. All rights reserved.