Interface RemoteQueryDispatcher

All Known Implementing Classes:
HttpRemoteQueryDispatcher

public interface RemoteQueryDispatcher
Sends a query to another member of the cluster and reports the responses it streams back.

Extracted as an interface so that routing a query can be exercised without a member to send it to.

Since:
5.4.0
Author:
Allard Buijze
  • Method Details

    • dispatch

      Sends the given query to the given member, reporting the responses it streams back.

      The returned stream is live: responses appear on it as the answering member produces them, and it completes when that member has answered in full. A failure reported by the answering member, or one reaching it, ends the stream in error. Closing the stream stops the member from being read any further.

      Parameters:
      member - the member to send the query to
      query - the query to send
      Returns:
      the stream of responses the given member answers with
    • openSubscriptionQueryUpdateStream

      MessageStream<QueryResponseMessage> openSubscriptionQueryUpdateStream(Member member, QueryMessage query, int updateBufferSize, RemoteQueryDispatcher.SubscriptionListener listener)
      Opens the stream of updates the given query produces on the given member.

      A streaming query like any other, except that it does not end of its own accord: the member keeps it open, emitting an update whenever the state the query reads changes, until it is released or the member reports a failure. Closing the stream releases the subscription.

      The stream completes normally only when the member says why it ends: because the subscription is over, or because the member is leaving the cluster and has stopped emitting updates. A stream the member ends without saying either fails, as does a lost connection, since the subscriber cannot know which updates it missed.

      Carries updates alone. The initial result of a subscription query is a query like any other, asked for with dispatch(Member, QueryMessage) once the update stream of every member advertising the query is open, so that an update emitted while that result is being produced still has somewhere to arrive. RemoteQueryDispatcher.SubscriptionListener.opened() is what says when that is for the given member: it runs once the member has registered the subscription, and so before any update it emits.

      Parameters:
      member - the member to open the update stream on
      query - the query to subscribe with
      updateBufferSize - how many updates to hold for this subscriber before failing the subscription
      listener - told when the member has registered the subscription, and when it reports the subscription over
      Returns:
      the updates the given member emits for the given query