public interface ERequestor extends EObject
open
a request feed and then
send
a request message. eBus forwards the request to all repliers
matching the given request. If there are no matching repliers
for the request, then ERequestFeed.request throws an
IllegalStateexception with the message "no repliers
for request". Otherwise, returns a
ERequestFeed.ERequest feed instance. At this point,
the requestor may expect to receive reply messages on the
reply(int, EReplyMessage, ERequestFeed.ERequest)
callback (or its replacement).
A request may be forwarded to more than one replier. Each
replier may send more than one reply. A requestor knows when a
final reply is received when the remaining parameter
is zero.
A requestor may cancel a request any time before the final
reply is received by calling
ERequestFeed.ERequest.close(). The
requestor may receive replies after this point if the reply
messages were scheduled for delivery prior to canceling the
request.
As of eBus v. 4.2.0, implementing the interface methods is no
longer necessary. Instead, Java lambda expressions may be used
to handle requestor callbacks. This is done by calling
ERequestFeed.statusCallback(FeedStatusCallback) and/or
ERequestFeed.replyCallback(ReplyCallback)
and using a lambda expression to specify the callback target.
Still, the application must either override ERequestor
interface methods or put callbacks in place. Failure
to do either results in ERequestFeed.subscribe()
failing. A class wishing to post requests must still implement
ERequestor even though it is no longer necessary to
override the interface methods.
It is possible to mix and match EReplier overrides and
callbacks. That is, a reply callback can be used in
conjunction with a
feedStatus(EFeedState, ERequestFeed)
override.
EReplier,
ERequestFeed.ERequest,
ERequestFeed,
ERequestMessage,
EReplyMessage| Modifier and Type | Method and Description |
|---|---|
default void |
feedStatus(EFeedState feedState,
ERequestFeed feed)
|
default void |
reply(int remaining,
EReplyMessage reply,
ERequestFeed.ERequest request)
eBus calls this method to deliver a reply message to the
corresponding
request. |
default void feedStatus(EFeedState feedState, ERequestFeed feed)
up) or no repliers
(down).
If down, then any call to
ERequestFeed.request(ERequestMessage) will result
in an IllegalStateException. If up, then a
request will attempt to post to the advertised repliers.
Note that an IllegalStateException may still be
thrown when the feed state is up because none of the
repliers accepted the request.
feedState - the subscription's new feed state.feed - the status applies to this feed.UnsupportedOperationException - if implementing class does not override this method nor
uses a callback.reply(int, EReplyMessage, ERequestFeed.ERequest)default void reply(int remaining,
EReplyMessage reply,
ERequestFeed.ERequest request)
request. The requestor can determine
that this is the final reply to the request when
remaining is zero.remaining - the number of replies yet to be received.
Zero means all replies received and no more will be
forthcoming.reply - the latest reply.request - the reply is for this request.UnsupportedOperationException - if implementing class does not override this method nor
uses a callback.feedStatus(EFeedState, ERequestFeed)Copyright © 2019. All rights reserved.