public final class EMultiRequestFeed extends EMultiFeed<ERequestMessage,ERequestFeed> implements IERequestFeed
ERequestFeeds on behalf of a ERequestor
client. A replier opens a multi-key reply feed for a specified
request message class and zero or more message subjects. These
subjects may be specified as a list or a regular expression
query. If a query is used, then the message class and subject
query are used to search the message key dictionary for all
matching subjects. The matching subjects are used to create
the initial subordinate ERequestFeeds.
The multi-key request feed coordinates the subordinate request feeds so they are given the same configuration and are in the same state (open, subscribed, un-subscribed, closed).
While the multi-key feed is open, new subordinate request
feeds may be added to or
removed from the multi-key feed.
Newly added subordinate feeds are configured and put into the
same state as the existing subordinate feeds.
EMultiFeed.MultiFeedFactory<M extends EMultiFeed,C extends EMessage,F extends EFeed>, EMultiFeed.SubordinateFeedFactory<R extends EObject,F extends net.sf.eBus.client.ESingleFeed>EFeed.AbstractClientTask, EFeed.FeedScope, EFeed.NotifyTask, EFeed.StatusTask<T extends IEFeed>mCondition, mFeeds, mMsgClass, MULTIFEED_SUBJECT, sLoggermEClient, mFeedId, mFeedState, mInPlace, mIsActive, mScope, NO_CONDITION, NOTIFY_METHOD| Modifier and Type | Method and Description |
|---|---|
protected ERequestFeed |
createFeed(EMessageKey key)
Returns a newly minted subordinate request feed for the
given key.
|
static EMultiRequestFeed |
open(ERequestor client,
Class<? extends ERequestMessage> mc,
List<String> subjects,
EFeed.FeedScope scope)
Returns an open multi-key feed for the given request
message class and message subjects list.
|
static EMultiRequestFeed |
open(ERequestor client,
Class<? extends ERequestMessage> mc,
Pattern query,
EFeed.FeedScope scope)
Returns an open multi-key request feed for a given
request message class and multiple message subjects.
|
protected void |
putFeedInPlace(ERequestFeed feed)
Sets the status and reply callbacks as per the multi-key
configuration and subscribes the subordinate feeds.
|
void |
replyCallback(Class<? extends EReplyMessage> mc,
ReplyCallback cb)
Sets the callback for a specific reply message class.
|
void |
replyCallback(ReplyCallback cb)
Puts the reply message callback in place
for all reply types.
|
ERequestFeed.ERequest |
request(ERequestMessage msg)
Posts a request message to all replier via the subordinate
request feed matching the message's key.
|
void |
statusCallback(FeedStatusCallback<ERequestFeed> cb)
Puts the feed status callback in place.
|
void |
subscribe()
Subscribes each subordinate
ERequestFeed. |
void |
unsubscribe()
Retracts this multi-key request feed by un-subscribing
each subordinate request feed.
|
addAllFeeds, addAllFeeds, addFeed, closeFeed, feedState, inactivate, isFeedUp, key, keys, messageClass, openList, openQuery, subjectsaddAllKeys, addKey, checkScopes, clientId, close, defaultDispatcher, eClient, equals, feedId, feedState, findKeys, findKeys, findKeys, hashCode, inPlace, isActive, isOverridden, loadKeys, location, register, register, register, scope, shutdown, shutdown, shutdownAll, startup, startup, startupAll, storeKeys, storeKeys, storeKeys, toStringpublic void statusCallback(FeedStatusCallback<ERequestFeed> cb)
cb is
not null, feed status updates will be passed to
cb rather than
ERequestor.feedStatus(EFeedState, ERequestFeed).
A null cb results in feed status updates posted to
the
ERequestor.feedStatus(EFeedState, ERequestFeed)
override.statusCallback in interface IERequestFeedcb - feed status update callback. May be
null.IllegalStateException - if this feed is either closed or subscribed.public void replyCallback(ReplyCallback cb)
cb is
not null, replies will be passed to cb
rather than
ERequestor.reply(int, EReplyMessage, ERequestFeed.ERequest).
A null cb results in replies posted to the
ERequestor.reply(int, EReplyMessage, ERequestFeed.ERequest)
override.
Note that this method call overrides all previous calls
to replyCallback(Class, ReplyCallback). If
the goal is to use a generic callback for all replies
except one specific message, then use this method to put
the generic callback in place first and then use
replyCallback(EMessageKey, ReplyCallback).
replyCallback in interface IERequestFeedcb - reply message callback. May be null.IllegalStateException - if this feed is either closed or subscribed.replyCallback(Class, ReplyCallback)public void replyCallback(Class<? extends EReplyMessage> mc, ReplyCallback cb)
cb is not null, replies will be passed to
cb rather than
ERequestor.reply(int, EReplyMessage, ERequestFeed.ERequest).
A cb results in replies posted to the
ERequestor.reply(int, EReplyMessage, ERequestFeed.ERequest)
override.
If the goal is to set a single callback method for all
reply message types, then use
replyCallback(ReplyCallback). Note that method
overrides all previous set reply callbacks.
replyCallback in interface IERequestFeedmc - the reply message class.cb - callback for the reply message.NullPointerException - if mc is null.IllegalArgumentException - if mc is not a reply for this request.IllegalStateException - if this feed is either closed or subscribed.protected ERequestFeed createFeed(EMessageKey key)
createFeed in class EMultiFeed<ERequestMessage,ERequestFeed>key - create a request feed for this key.protected void putFeedInPlace(ERequestFeed feed)
putFeedInPlace in class EMultiFeed<ERequestMessage,ERequestFeed>feed - advertise this subordinate request feed.public static EMultiRequestFeed open(ERequestor client, Class<? extends ERequestMessage> mc, List<String> subjects, EFeed.FeedScope scope)
ERequestFeed.
It is the subordinate request feeds which call back to
client, not the opened multi-key feed. So if
subjects contains 1,000 subjects, then
client receives status callbacks from 1,000
subordinate request feeds.
subjects may be a non-null, empty list
resulting in no initial subordinate request feeds opened.
This allows the requestor to start with an empty
multi-key request feed, adding
subordinate feeds later.
client - the eBus requestor opening this feed.mc - request message class. All feeds apply to
this message class.subjects - list of request message subjects. May not
contain null or empty strings but this list may be
empty.scope - whether the feed supports local feeds,
remote feeds, or both.NullPointerException - if any of the arguments is null.IllegalArgumentException - if subjects contains an empty string.open(ERequestor, Class, Pattern, EFeed.FeedScope),
subscribe(),
EFeed.close(),
EMultiFeed.addFeed(String),
EMultiFeed.closeFeed(String)public static EMultiRequestFeed open(ERequestor client, Class<? extends ERequestMessage> mc, Pattern query, EFeed.FeedScope scope)
ERequestFeed.
The subordinate request feeds are selected based on the
given request message class and the regular expression
query. The multi-key request feed is opened whether the
message key dictionary entries match the message class and
subject query or not. In either case, the application may
add more subordinate feeds to the
returned multi-key feed.
Note: client receives callbacks
from subordinate ERequestFeed feeds, not the
multi-key feed. If mc and query match
1,000 request message keys, then client will
receive feed status and notify callbacks from those 1,000
subordinate feeds.
client - application object subscribing to the
request message class and matching subjects.mc - the message key query is for this request
message class only.query - message key subject query.scope - whether the feed supports local feeds, remote
feeds, or both.open(ERequestor, Class, List, EFeed.FeedScope),
subscribe(),
EFeed.close(),
EMultiFeed.addFeed(String),
EMultiFeed.closeFeed(String)public void subscribe()
ERequestFeed. If this
feed is currently subscribed, then does nothing. The
requestor client will receive a
ERequestor.feedStatus(EFeedState, ERequestFeed)
callback from each subordinate request feed.subscribe in interface IERequestFeedIllegalStateException - if this feed is closed or the client did not override
not put in place the required callback methods.unsubscribe(),
EFeed.close()public void unsubscribe()
unsubscribe in interface IERequestFeedIllegalStateException - if this multi-key request feed is closed.subscribe(),
EFeed.close()public ERequestFeed.ERequest request(ERequestMessage msg)
msg - post this request message to the matching
subordinate feed.ERequestFeed.ERequest feed used to
interact with the active request.NullPointerException - if msg is null.IllegalArgumentException - if msg message key does not reference a known
subordinate reply feed.IllegalStateException - if this feed is inactive, not advertised, or there are no
repliers available to respond to the request.Copyright © 2019. All rights reserved.