Interface QueryGateway
- All Superinterfaces:
DescribableComponent
- All Known Implementing Classes:
DefaultQueryGateway
This interface provides a friendlier API toward the QueryBus.
- Since:
- 3.1.0
- Author:
- Allard Buijze, Marc Gathier, Milan Savic, Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptiondefault <R> CompletableFuture<R> Sends givenqueryover theQueryBus, expecting a single response with the givenresponseTypefrom a single source.<R> CompletableFuture<R> query(Object query, Class<R> responseType, ProcessingContext context) Sends givenqueryover theQueryBus, expecting a single response with the givenresponseTypefrom a single source.default <R> CompletableFuture<List<R>> Sends givenqueryover theQueryBus, expecting multiple responses in the form ofresponseTypefrom a single source.<R> CompletableFuture<List<R>> queryMany(Object query, Class<R> responseType, ProcessingContext context) Sends givenqueryover theQueryBus, expecting multiple responses in the form ofresponseTypefrom a single source.default <R> org.reactivestreams.Publisher<R> streamingQuery(Object query, Class<R> responseType) <R> org.reactivestreams.Publisher<R> streamingQuery(Object query, Class<R> responseType, ProcessingContext context) default <R> org.reactivestreams.Publisher<R> subscriptionQuery(Object query, Class<R> responseType) Sends givenqueryover theQueryBusas a subscription query, combining the initial result and emitted update as aPublisherof the givenresponseType.default <R> org.reactivestreams.Publisher<R> subscriptionQuery(Object query, Class<R> responseType, int updateBufferSize) Sends givenqueryover theQueryBusand returns aPublishersupplying the initial update followed by the update.default <R> org.reactivestreams.Publisher<R> subscriptionQuery(Object query, Class<R> responseType, Function<QueryResponseMessage, R> mapper) Sends givenqueryover theQueryBusand returns aPublishersupplying the initial update followed by the update.default <R> org.reactivestreams.Publisher<R> subscriptionQuery(Object query, Class<R> responseType, Function<QueryResponseMessage, R> mapper, int updateBufferSize) Sends givenqueryover theQueryBusand returns aPublishersupplying the initial update followed by the update.default <R> org.reactivestreams.Publisher<R> subscriptionQuery(Object query, Class<R> responseType, Function<QueryResponseMessage, R> mapper, ProcessingContext context) Sends givenqueryover theQueryBusand returns aPublishersupplying the initial update followed by the update.<R> org.reactivestreams.Publisher<R> subscriptionQuery(Object query, Class<R> responseType, Function<QueryResponseMessage, R> mapper, ProcessingContext context, int updateBufferSize) Sends givenqueryover theQueryBusand returns aPublishersupplying the initial update followed by the update.default <R> org.reactivestreams.Publisher<R> subscriptionQuery(Object query, Class<R> responseType, ProcessingContext context) Sends givenqueryover theQueryBusas a subscription query, combining the initial result and emitted update as aPublisherof the givenresponseType.<R> org.reactivestreams.Publisher<R> subscriptionQuery(Object query, Class<R> responseType, ProcessingContext context, int updateBufferSize) Sends givenqueryover theQueryBusas a subscription query, combining the initial result and emitted update as aPublisherof the givenresponseType.Methods inherited from interface org.axonframework.common.infra.DescribableComponent
describeTo
-
Method Details
-
query
@Nonnull <R> CompletableFuture<R> query(@Nonnull Object query, @Nonnull Class<R> responseType, @Nullable ProcessingContext context) Sends givenqueryover theQueryBus, expecting a single response with the givenresponseTypefrom a single source.Execution may be asynchronous, depending on the
QueryBusimplementation.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.- Type Parameters:
R- The generic type of the expected response.- Parameters:
query- Thequeryto be sent.responseType- AClassdescribing the desired response type.context- The processing context, if any, to dispatch the givenqueryin.- Returns:
- A
CompletableFuturecontaining a single query response of typeresponseType.
-
query
@Nonnull default <R> CompletableFuture<R> query(@Nonnull Object query, @Nonnull Class<R> responseType) Sends givenqueryover theQueryBus, expecting a single response with the givenresponseTypefrom a single source.Execution may be asynchronous, depending on the
QueryBusimplementation.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.- Type Parameters:
R- The generic type of the expected response.- Parameters:
query- Thequeryto be sent.responseType- AClassdescribing the desired response type.- Returns:
- A
CompletableFuturecontaining a single query response of typeresponseType. - See Also:
-
queryMany
@Nonnull <R> CompletableFuture<List<R>> queryMany(@Nonnull Object query, @Nonnull Class<R> responseType, @Nullable ProcessingContext context) Sends givenqueryover theQueryBus, expecting multiple responses in the form ofresponseTypefrom a single source.Execution may be asynchronous, depending on the
QueryBusimplementation.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.- Type Parameters:
R- The generic type of the expected response(s).- Parameters:
query- Thequeryto be sent.responseType- AClassdescribing the desired response type.context- The processing context, if any, to dispatch the givenqueryin.- Returns:
- A
CompletableFuturecontaining a list of query responses of typeresponseType.
-
queryMany
@Nonnull default <R> CompletableFuture<List<R>> queryMany(@Nonnull Object query, @Nonnull Class<R> responseType) Sends givenqueryover theQueryBus, expecting multiple responses in the form ofresponseTypefrom a single source.Execution may be asynchronous, depending on the
QueryBusimplementation.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.- Type Parameters:
R- The generic type of the expected response(s).- Parameters:
query- Thequeryto be sent.responseType- AClassdescribing the desired response type.- Returns:
- A
CompletableFuturecontaining a list of query responses of typeresponseType. - See Also:
-
streamingQuery
@Nonnull <R> org.reactivestreams.Publisher<R> streamingQuery(@Nonnull Object query, @Nonnull Class<R> responseType, @Nullable ProcessingContext context) Sends givenqueryover theQueryBus, expecting a response as aPublisherofresponseType.The
queryis sent once thePublisheris subscribed to. The streaming query allows a client to stream large result sets. Usage of this method requires Project Reactor on the class path.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.Publisheris used for backwards compatibility reason, for clients that don't have Project Reactor on class path. Check Reactor Extension for native Flux type and more. UseFlux.from(publisher)to convert to Flux stream.- Type Parameters:
R- The generic type of the expected response(s).- Parameters:
query- Thequeryto be sent.responseType- AClassdescribing the desired response type.context- The processing context, if any, to dispatch the givenqueryin.- Returns:
- A
Publisherstreaming the results as dictated by the givenresponseType.
-
streamingQuery
@Nonnull default <R> org.reactivestreams.Publisher<R> streamingQuery(@Nonnull Object query, @Nonnull Class<R> responseType) Sends givenqueryover theQueryBus, expecting a response as aPublisherofresponseType.The
queryis sent once thePublisheris subscribed to. The streaming query allows a client to stream large result sets. Usage of this method requires Project Reactor on the class path.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.Publisheris used for backwards compatibility reason, for clients that don't have Project Reactor on class path. Check Reactor Extension for native Flux type and more. UseFlux.from(publisher)to convert to Flux stream.- Type Parameters:
R- The generic type of the expected response(s).- Parameters:
query- Thequeryto be sent.responseType- AClassdescribing the desired response type.- Returns:
- A
Publisherstreaming the results as dictated by the givenresponseType. - See Also:
-
subscriptionQuery
@Nonnull default <R> org.reactivestreams.Publisher<R> subscriptionQuery(@Nonnull Object query, @Nonnull Class<R> responseType, @Nullable ProcessingContext context) Sends givenqueryover theQueryBusas a subscription query, combining the initial result and emitted update as aPublisherof the givenresponseType.The
queryis sent once thePublisheris subscribed to. Furthermore, update are received at the moment the query is sent, and until it is cancelled by the caller or closed by the emitting side.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.Note that any
nullresults, on the initial result or the update, wil lbe filtered out by the gateway. If you require thenullto be returned for the initial and update results, we suggest using theQueryBusinstead.The returned Publisher must be subscribed to and consumed from before the buffer fills up. Once the buffer is full, any attempt to add an update will complete the stream with an exception.
- Type Parameters:
R- The type of all the responses.- Parameters:
query- Thequeryto be sent.responseType- The response type returned by this query as the initial result and the update.context- The processing context, if any, to dispatch the givenqueryin.- Returns:
- A
Publisherstreaming the results as dictated by the givenresponseType.
-
subscriptionQuery
@Nonnull default <R> org.reactivestreams.Publisher<R> subscriptionQuery(@Nonnull Object query, @Nonnull Class<R> responseType) Sends givenqueryover theQueryBusas a subscription query, combining the initial result and emitted update as aPublisherof the givenresponseType.The
queryis sent once thePublisheris subscribed to. Furthermore, update are received at the moment the query is sent, and until it is cancelled by the caller or closed by the emitting side.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.Note that any
nullresults, on the initial result or the update, wil lbe filtered out by the gateway. If you require thenullto be returned for the initial and update results, we suggest using theQueryBusinstead.The returned Publisher must be subscribed to and consumed from before the buffer fills up. Once the buffer is full, any attempt to add an update will complete the stream with an exception.
- Type Parameters:
R- The type of all the responses.- Parameters:
query- Thequeryto be sent.responseType- The response type returned by this query as the initial result and the update.- Returns:
- A
Publisherstreaming the results as dictated by the givenresponseType.
-
subscriptionQuery
@Nonnull <R> org.reactivestreams.Publisher<R> subscriptionQuery(@Nonnull Object query, @Nonnull Class<R> responseType, @Nullable ProcessingContext context, int updateBufferSize) Sends givenqueryover theQueryBusas a subscription query, combining the initial result and emitted update as aPublisherof the givenresponseType.The
queryis sent once thePublisheris subscribed to. Furthermore, update are received at the moment the query is sent, and until it is cancelled by the caller or closed by the emitting side.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.Note that any
nullresults, on the initial result or the update, will be filtered out by the gateway. If you require thenullto be returned for the initial and update results, we suggest using theQueryBusinstead.The returned Publisher must be subscribed to and consumed from before the buffer fills up. Once the buffer is full, any attempt to add an update will complete the stream with an exception.
- Type Parameters:
R- The type of all the responses.- Parameters:
query- Thequeryto be sent.responseType- The response type returned by this query as the initial result and the update.context- The processing context, if any, to dispatch the givenqueryin.updateBufferSize- The size of buffer which accumulates update before a subscription to theFluxis made.- Returns:
- A
Publisherstreaming the results as dictated by the givenresponseType.
-
subscriptionQuery
@Nonnull default <R> org.reactivestreams.Publisher<R> subscriptionQuery(@Nonnull Object query, @Nonnull Class<R> responseType, @Nonnull Function<QueryResponseMessage, R> mapper, @Nullable ProcessingContext context) Sends givenqueryover theQueryBusand returns aPublishersupplying the initial update followed by the update. The givenmapperis used to map theQueryResponseMessageto the desired object type. To distinguish between the initial result and the update, the givenmappercan check whether the givenresponseMessageis an instance ofSubscriptionQueryUpdateMessage. In that case the message is considered an update, otherwise it is considered the initial result.The
queryis sent upon invocation of this method. Furthermore, update are received at the moment the query is sent, and until the subscription to the Publisher is canceled by the caller or closed by the emitting side.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.Note that any
nullresults, on the initial result or the update, will be filtered out by the gateway. If you require thenullto be returned for the initial and update results, we suggest using theQueryBusinstead.The returned Publisher must be subscribed to and consumed from before the buffer fills up. Once the buffer is full, any attempt to add an update will complete the stream with an exception. To control the buffer size, use
subscriptionQuery(Object, Class, Function, ProcessingContext, int).- Type Parameters:
R- The type payload to map the responses to.- Parameters:
query- Thequeryto be sent.responseType- The response type returned by this query as the initial resultmapper- AFunctionthat maps theQueryResponseMessageto the desired responsecontext- The processing context, if any, to dispatch the givenqueryin.- Returns:
- Registration which can be used to cancel receiving update.
- See Also:
-
subscriptionQuery
@Nonnull default <R> org.reactivestreams.Publisher<R> subscriptionQuery(@Nonnull Object query, @Nonnull Class<R> responseType, @Nonnull Function<QueryResponseMessage, R> mapper) Sends givenqueryover theQueryBusand returns aPublishersupplying the initial update followed by the update. The givenmapperis used to map theQueryResponseMessageto the desired object type. To distinguish between the initial result and the update, the givenmappercan check whether the givenresponseMessageis an instance ofSubscriptionQueryUpdateMessage. In that case the message is considered an update, otherwise it is considered the initial result.The
queryis sent upon invocation of this method. Furthermore, update are received at the moment the query is sent, and until the subscription to the Publisher is canceled by the caller or closed by the emitting side.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.Note that any
nullresults, on the initial result or the update, will be filtered out by the gateway. If you require thenullto be returned for the initial and update results, we suggest using theQueryBusinstead.The returned Publisher must be subscribed to and consumed from before the buffer fills up. Once the buffer is full, any attempt to add an update will complete the stream with an exception. To control the buffer size, use
subscriptionQuery(Object, Class, Function, ProcessingContext, int).- Type Parameters:
R- The type payload to map the responses to.- Parameters:
query- Thequeryto be sent.responseType- The response type returned by this query as the initial resultmapper- AFunctionthat maps theQueryResponseMessageto the desired response- Returns:
- Registration which can be used to cancel receiving update.
- See Also:
-
subscriptionQuery
@Nonnull default <R> org.reactivestreams.Publisher<R> subscriptionQuery(@Nonnull Object query, @Nonnull Class<R> responseType, int updateBufferSize) Sends givenqueryover theQueryBusand returns aPublishersupplying the initial update followed by the update. The givenmapperis used to map theQueryResponseMessageto the desired object type. To distinguish between the initial result and the update, the givenmappercan check whether the givenresponseMessageis an instance ofSubscriptionQueryUpdateMessage. In that case the message is considered an update, otherwise it is considered the initial result.The
queryis sent upon invocation of this method. Furthermore, update are received at the moment the query is sent, and until the subscription to the Publisher is canceled by the caller or closed by the emitting side.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.Note that any
nullresults, on the initial result or the update, will be filtered out by the gateway. If you require thenullto be returned for the initial and update results, we suggest using theQueryBusinstead.- Type Parameters:
R- The type payload to map the responses to.- Parameters:
query- Thequeryto be sent.responseType- The response type returned by this query as the initial resultupdateBufferSize- The size of the buffer which accumulates update to be processed.- Returns:
- Registration which can be used to cancel receiving update.
- See Also:
-
subscriptionQuery
@Nonnull <R> org.reactivestreams.Publisher<R> subscriptionQuery(@Nonnull Object query, @Nonnull Class<R> responseType, @Nonnull Function<QueryResponseMessage, R> mapper, @Nullable ProcessingContext context, int updateBufferSize) Sends givenqueryover theQueryBusand returns aPublishersupplying the initial update followed by the update. The givenmapperis used to map theQueryResponseMessageto the desired object type. To distinguish between the initial result and the update, the givenmappercan check whether the givenresponseMessageis an instance ofSubscriptionQueryUpdateMessage. In that case the message is considered an update, otherwise it is considered the initial result.The
queryis sent upon invocation of this method. Furthermore, update are received at the moment the query is sent, and until the subscription to the Publisher is canceled by the caller or closed by the emitting side.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.Note that any
nullresults, on the initial result or the update, will be filtered out by the gateway. If you require thenullto be returned for the initial and update results, we suggest using theQueryBusinstead.- Type Parameters:
R- The type payload to map the responses to.- Parameters:
query- Thequeryto be sent.responseType- The response type returned by this query as the initial resultmapper- AFunctionthat maps theQueryResponseMessageto the desired response. Messages for which the mapper returns anullvalue are filtered out.context- The processing context, if any, to dispatch the givenqueryin.updateBufferSize- The size of the buffer which accumulates update to be processed.- Returns:
- Registration which can be used to cancel receiving update.
- See Also:
-
subscriptionQuery
@Nonnull default <R> org.reactivestreams.Publisher<R> subscriptionQuery(@Nonnull Object query, @Nonnull Class<R> responseType, @Nonnull Function<QueryResponseMessage, R> mapper, int updateBufferSize) Sends givenqueryover theQueryBusand returns aPublishersupplying the initial update followed by the update. The givenmapperis used to map theQueryResponseMessageto the desired object type. To distinguish between the initial result and the update, the givenmappercan check whether the givenresponseMessageis an instance ofSubscriptionQueryUpdateMessage. In that case the message is considered an update, otherwise it is considered the initial result.The
queryis sent upon invocation of this method. Furthermore, update are received at the moment the query is sent, and until the subscription to the Publisher is canceled by the caller or closed by the emitting side.The given
queryis wrapped as the payload of theQueryMessagethat is eventually posted on theQueryBus, unless thequeryalready implementsMessage. In that case, aQueryMessageis constructed from that message's payload andMetadata.Note that any
nullresults, on the initial result or the update, will be filtered out by the gateway. If you require thenullto be returned for the initial and update results, we suggest using theQueryBusinstead.- Type Parameters:
R- The type payload to map the responses to.- Parameters:
query- Thequeryto be sent.responseType- The response type returned by this query as the initial resultmapper- AFunctionthat maps theQueryResponseMessageto the desired response. Messages for which the mapper returns anullvalue are filtered out.updateBufferSize- The size of the buffer which accumulates update to be processed.- Returns:
- Registration which can be used to cancel receiving update.
- See Also:
-