Interface QueryGateway

All Superinterfaces:
MessageDispatchInterceptorSupport<QueryMessage<?,?>>
All Known Implementing Classes:
DefaultQueryGateway

public interface QueryGateway extends MessageDispatchInterceptorSupport<QueryMessage<?,?>>
Interface towards the Query Handling components of an application. This interface provides a friendlier API toward the query bus.
Since:
3.1
Author:
Marc Gathier, Allard Buijze, Steven van Beelen, Milan Savic
  • Method Details

    • query

      default <R, Q> CompletableFuture<R> query(@Nonnull Q query, @Nonnull Class<R> responseType)
      Sends given query over the QueryBus, expecting a response with the given responseType from a single source. The query name will be derived from the provided query. Execution may be asynchronous, depending on the QueryBus implementation.
      Type Parameters:
      R - The response class contained in the given responseType
      Q - The query class
      Parameters:
      query - The query to be sent
      responseType - A Class describing the desired response type
      Returns:
      A CompletableFuture containing the query result as dictated by the given responseType
    • query

      default <R, Q> CompletableFuture<R> query(@Nonnull String queryName, @Nonnull Q query, @Nonnull Class<R> responseType)
      Sends given query over the QueryBus, expecting a response with the given responseType from a single source. Execution may be asynchronous, depending on the QueryBus implementation.
      Type Parameters:
      R - The response class contained in the given responseType
      Q - The query class
      Parameters:
      queryName - A String describing the query to be executed
      query - The query to be sent
      responseType - The ResponseType used for this query
      Returns:
      A CompletableFuture containing the query result as dictated by the given responseType
    • query

      default <R, Q> CompletableFuture<R> query(@Nonnull Q query, @Nonnull ResponseType<R> responseType)
      Sends given query over the QueryBus, expecting a response in the form of responseType from a single source. The query name will be derived from the provided query. Execution may be asynchronous, depending on the QueryBus implementation.
      Type Parameters:
      R - The response class contained in the given responseType
      Q - The query class
      Parameters:
      query - The query to be sent
      responseType - The ResponseType used for this query
      Returns:
      A CompletableFuture containing the query result as dictated by the given responseType
    • query

      <R, Q> CompletableFuture<R> query(@Nonnull String queryName, @Nonnull Q query, @Nonnull ResponseType<R> responseType)
      Sends given query over the QueryBus, expecting a response in the form of responseType from a single source. Execution may be asynchronous, depending on the QueryBus implementation.
      Type Parameters:
      R - The response class contained in the given responseType
      Q - The query class
      Parameters:
      queryName - A String describing the query to be executed
      query - The query to be sent
      responseType - The ResponseType used for this query
      Returns:
      A CompletableFuture containing the query result as dictated by the given responseType
    • streamingQuery

      default <R, Q> org.reactivestreams.Publisher<R> streamingQuery(Q query, Class<R> responseType)
      Sends given query over the QueryBus, expecting a response as Publisher of responseType. Query is sent once Publisher is subscribed to. The Streaming query allows a client to stream large result sets. Usage of this method requires Project Reactor on the class path. Publisher is 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. Use Flux.from(publisher) to convert to Flux stream.
      Type Parameters:
      R - The response class contained in the given responseType
      Q - The query class
      Parameters:
      query - The query to be sent
      responseType - A Class describing the desired response type
      Returns:
      A Publisher streaming the results as dictated by the given responseType
    • streamingQuery

      <R, Q> org.reactivestreams.Publisher<R> streamingQuery(String queryName, Q query, Class<R> responseType)
      Sends given query over the QueryBus, expecting a response as Publisher of responseType. Query is sent once Publisher is subscribed to. The Streaming query allows a client to stream large result sets. Usage of this method requires Project Reactor on the class path. Publisher is 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. Use Flux.from(publisher) to convert to Flux stream.
      Type Parameters:
      R - The response class contained in the given responseType
      Q - The query class
      Parameters:
      queryName - A String describing the query to be executed
      query - The query to be sent
      responseType - A Class describing the desired response type
      Returns:
      A Publisher streaming the results as dictated by the given responseType.
    • scatterGather

      default <R, Q> Stream<R> scatterGather(@Nonnull Q query, @Nonnull ResponseType<R> responseType, long timeout, @Nonnull TimeUnit timeUnit)
      Sends given query over the QueryBus, expecting a response in the form of responseType from several sources. The stream is completed when a timeout occurs or when all results are received. The query name will be derived from the provided query. Execution may be asynchronous, depending on the QueryBus implementation.
      Type Parameters:
      R - The response class contained in the given responseType
      Q - The query class
      Parameters:
      query - The query to be sent
      responseType - The ResponseType used for this query
      timeout - A timeout of long for the query
      timeUnit - The selected TimeUnit for the given timeout
      Returns:
      A stream of results.
    • scatterGather

      <R, Q> Stream<R> scatterGather(@Nonnull String queryName, @Nonnull Q query, @Nonnull ResponseType<R> responseType, long timeout, @Nonnull TimeUnit timeUnit)
      Sends given query over the QueryBus, expecting a response in the form of responseType from several sources. The stream is completed when a timeout occurs or when all results are received. Execution may be asynchronous, depending on the QueryBus implementation.
      Type Parameters:
      R - The response class contained in the given responseType
      Q - The query class
      Parameters:
      queryName - A String describing the query to be executed
      query - The query to be sent
      responseType - The ResponseType used for this query
      timeout - A timeout of long for the query
      timeUnit - The selected TimeUnit for the given timeout
      Returns:
      A stream of results.
    • subscriptionQuery

      default <Q, I, U> SubscriptionQueryResult<I,U> subscriptionQuery(@Nonnull Q query, @Nonnull Class<I> initialResponseType, @Nonnull Class<U> updateResponseType)
      Sends given query over the QueryBus and returns result containing initial response and incremental updates (received at the moment the query is sent, until it is cancelled by the caller or closed by the emitting side).

      Note: Any null results, on the initial result or the updates, wil lbe filtered out by the QueryGateway. If you require the null to be returned for the initial and update results, we suggest using the QueryBus instead.

      Type Parameters:
      Q - The type of the query
      I - The type of the initial response
      U - The type of the incremental update
      Parameters:
      query - The query to be sent
      initialResponseType - The initial response type used for this query
      updateResponseType - The update response type used for this query
      Returns:
      registration which can be used to cancel receiving updates
      See Also:
    • subscriptionQuery

      default <Q, I, U> SubscriptionQueryResult<I,U> subscriptionQuery(@Nonnull String queryName, @Nonnull Q query, @Nonnull Class<I> initialResponseType, @Nonnull Class<U> updateResponseType)
      Sends given query over the QueryBus and returns result containing initial response and incremental updates (received at the moment the query is sent, until it is cancelled by the caller or closed by the emitting side).

      Note: Any null results, on the initial result or the updates, wil lbe filtered out by the QueryGateway. If you require the null to be returned for the initial and update results, we suggest using the QueryBus instead.

      Type Parameters:
      Q - The type of the query
      I - The type of the initial response
      U - The type of the incremental update
      Parameters:
      queryName - A String describing query to be executed
      query - The query to be sent
      initialResponseType - The initial response type used for this query
      updateResponseType - The update response type used for this query
      Returns:
      registration which can be used to cancel receiving updates
      See Also:
    • subscriptionQuery

      default <Q, I, U> SubscriptionQueryResult<I,U> subscriptionQuery(@Nonnull Q query, @Nonnull ResponseType<I> initialResponseType, @Nonnull ResponseType<U> updateResponseType)
      Sends given query over the QueryBus and returns result containing initial response and incremental updates (received at the moment the query is sent, until it is cancelled by the caller or closed by the emitting side).

      Note: Any null results, on the initial result or the updates, wil lbe filtered out by the QueryGateway. If you require the null to be returned for the initial and update results, we suggest using the QueryBus instead.

      Type Parameters:
      Q - The type of the query
      I - The type of the initial response
      U - The type of the incremental update
      Parameters:
      query - The query to be sent
      initialResponseType - The initial response type used for this query
      updateResponseType - The update response type used for this query
      Returns:
      registration which can be used to cancel receiving updates
      See Also:
    • subscriptionQuery

      @Deprecated default <Q, I, U> SubscriptionQueryResult<I,U> subscriptionQuery(@Nonnull String queryName, @Nonnull Q query, @Nonnull ResponseType<I> initialResponseType, @Nonnull ResponseType<U> updateResponseType, @Nullable SubscriptionQueryBackpressure backpressure)
      Deprecated.
      in favour of using {subscriptionQuery(String, Object, ResponseType, ResponseType)}. To set a backpressure strategy, use one of the onBackpressure.. operators on the updates flux directly. Example: result.updates().onBackpressureBuffer(100)
      Sends given query over the QueryBus and returns result containing initial response and incremental updates (received at the moment the query is sent, until it is cancelled by the caller or closed by the emitting side).

      Note: Any null results, on the initial result or the updates, wil lbe filtered out by the QueryGateway. If you require the null to be returned for the initial and update results, we suggest using the QueryBus instead.

      Type Parameters:
      Q - The type of the query
      I - The type of the initial response
      U - The type of the incremental update
      Parameters:
      queryName - A String describing query to be executed
      query - The query to be sent
      initialResponseType - The initial response type used for this query
      updateResponseType - The update response type used for this query
      backpressure - The backpressure mechanism to deal with producing of incremental updates
      Returns:
      registration which can be used to cancel receiving updates
      See Also:
    • subscriptionQuery

      default <Q, I, U> SubscriptionQueryResult<I,U> subscriptionQuery(@Nonnull String queryName, @Nonnull Q query, @Nonnull ResponseType<I> initialResponseType, @Nonnull ResponseType<U> updateResponseType)
      Sends given query over the QueryBus and returns result containing initial response and incremental updates (received at the moment the query is sent, until it is cancelled by the caller or closed by the emitting side).

      Note: Any null results, on the initial result or the updates, will be filtered out by the QueryGateway. If you require the null to be returned for the initial and update results, we suggest using the QueryBus instead.

      Type Parameters:
      Q - the type of the query
      I - the type of the initial response
      U - the type of the incremental update
      Parameters:
      queryName - a String describing query to be executed
      query - the query to be sent
      initialResponseType - the initial response type used for this query
      updateResponseType - the update response type used for this query
      Returns:
      registration which can be used to cancel receiving updates
      See Also:
    • subscriptionQuery

      @Deprecated <Q, I, U> SubscriptionQueryResult<I,U> subscriptionQuery(@Nonnull String queryName, @Nonnull Q query, @Nonnull ResponseType<I> initialResponseType, @Nonnull ResponseType<U> updateResponseType, @Nullable SubscriptionQueryBackpressure backpressure, int updateBufferSize)
      Deprecated.
      in favour of using {subscriptionQuery(String, Object, ResponseType, ResponseType, int)}. To set a backpressure strategy, use one of the onBackpressure.. operators on the updates flux directly. Example: result.updates().onBackpressureBuffer(100)
      Sends given query over the QueryBus and returns result containing initial response and incremental updates (received at the moment the query is sent, until it is cancelled by the caller or closed by the emitting side).

      Note: Any null results, on the initial result or the updates, wil lbe filtered out by the QueryGateway. If you require the null to be returned for the initial and update results, we suggest using the QueryBus instead.

      Type Parameters:
      Q - The type of the query
      I - The type of the initial response
      U - The type of the incremental update
      Parameters:
      queryName - A String describing query to be executed
      query - The query to be sent
      initialResponseType - The initial response type used for this query
      updateResponseType - The update response type used for this query
      backpressure - The backpressure mechanism to deal with producing of incremental updates
      updateBufferSize - The size of buffer which accumulates updates before subscription to the flux is made
      Returns:
      registration which can be used to cancel receiving updates
      See Also:
    • subscriptionQuery

      <Q, I, U> SubscriptionQueryResult<I,U> subscriptionQuery(@Nonnull String queryName, @Nonnull Q query, @Nonnull ResponseType<I> initialResponseType, @Nonnull ResponseType<U> updateResponseType, int updateBufferSize)
      Sends given query over the QueryBus and returns result containing initial response and incremental updates (received at the moment the query is sent, until it is cancelled by the caller or closed by the emitting side).

      Note: Any null results, on the initial result or the updates, wil lbe filtered out by the QueryGateway. If you require the null to be returned for the initial and update results, we suggest using the QueryBus instead.

      Type Parameters:
      Q - the type of the query
      I - the type of the initial response
      U - the type of the incremental update
      Parameters:
      queryName - a String describing query to be executed
      query - the query to be sent
      initialResponseType - the initial response type used for this query
      updateResponseType - the update response type used for this query
      updateBufferSize - the size of buffer which accumulates updates before subscription to the flux is made
      Returns:
      registration which can be used to cancel receiving updates
      See Also: