Interface RemoteQueryDispatcher
- All Known Implementing Classes:
HttpRemoteQueryDispatcher
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
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceWhat a member reports about a subscription besides the updates themselves. -
Method Summary
Modifier and TypeMethodDescriptiondispatch(Member member, QueryMessage query) Sends the givenqueryto the givenmember, reporting the responses it streams back.openSubscriptionQueryUpdateStream(Member member, QueryMessage query, int updateBufferSize, RemoteQueryDispatcher.SubscriptionListener listener) Opens the stream of updates the givenqueryproduces on the givenmember.
-
Method Details
-
dispatch
Sends the givenqueryto the givenmember, 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 toquery- the query to send- Returns:
- the stream of responses the given
memberanswers with
-
openSubscriptionQueryUpdateStream
MessageStream<QueryResponseMessage> openSubscriptionQueryUpdateStream(Member member, QueryMessage query, int updateBufferSize, RemoteQueryDispatcher.SubscriptionListener listener) Opens the stream of updates the givenqueryproduces on the givenmember.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 givenmember: 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 onquery- the query to subscribe withupdateBufferSize- how many updates to hold for this subscriber before failing the subscriptionlistener- told when the member has registered the subscription, and when it reports the subscription over- Returns:
- the updates the given
memberemits for the givenquery
-