public final class EPublishFeed extends ENotifyFeed
EPublishFeedis the application entry point for publishing
notification messagesto subscribers. Follow these steps to use this feed:
Step 1: Implement the
Step 5: Wait for the
callback where the feed state is
Attempting to publish before this will result in
publish(ENotificationMessage) throwing an
Step 6: Start publishing notifications. Note
updateFeedState(EFeedState) with an up feed state
must be done prior to publishing notifications.
The first might be an external device connected to a serial
port, providing intermittent data updates. The eBus publisher
converts that data into notification messages. If the serial
interface is unreliable and goes down, the eBus publisher
updateFeedState(EFeedState.DOWN) to inform
subscribers about the fact.
The second is a publisher which also subscribes to one or more other feeds, publishing a value-added notification based on the inbound notifications. If one of the subscribed feeds goes down, then the publisher sets its feed state to down. When the subscribed feed is back up, then the publisher is also back up.
The above scenarios could also be accomplished by having the
the feed is down and up, respectively. But eBus expends much
effort doing this. It is less effort to leave the
advertisement in place and update the feed state.
|Modifier and Type||Method and Description|
Advertises this publisher feed to the associated notification subject.
If the feed state is up, then informs the notify subject that it is now down.
Returns a notification publish feed for the specified notification message class and subject.
Posts this notification message to all interested subscribers.
Returns the publish state.
Puts the publish status callback in place.
Retracts this publisher feed from the associated notification subject.
Updates the publish feed state to the given value.
activationCount, addAllKeys, addKey, clientId, close, defaultDispatcher, equals, feedId, feedState, findKeys, findKeys, findKeys, hashCode, inPlace, isActive, isOverridden, key, loadKeys, location, messageSubject, register, register, register, scope, shutdown, shutdown, shutdownAll, startup, startup, startupAll, storeKeys, storeKeys, storeKeys, toString
protected void inactivate()
public boolean isAdvertised()
trueif this publish feed is both open and advertised; otherwise, returns
true is returned, that does not
mean that the publisher is clear to publish notification
messages. The publisher should only post messages when
public EFeedState publishState()
EFeedState.UPif there is any subscriber to this feed. The publish state specifies whether the publisher is capable of publishing messages for this feed.
public boolean isFeedUp()
trueif the publisher is clear to publish a notification and
falseif not clear. When
trueis returned, that means that this feed is 1) open, 2) advertised, 3) the publish state is up, and 4) there are subscribers listening to this notification feed.
public static EPublishFeed open(EPublisher client, EMessageKey key, EFeed.FeedScope scope)
client- the application object publishing the notification. May not be
key- the notification message class and subject. May not be
nulland must reference a notification message class.
scope- whether the feed supports local feeds, remote feeds, or both.
java.lang.NullPointerException- if any of the arguments are
java.lang.IllegalArgumentException- if any of the arguments is invalid.
public void statusCallback(FeedStatusCallback<EPublishFeed> cb)
null, publish status updates will be passed to
EPublisher.publishStatus(EFeedState, EPublishFeed). The reverse is true if
null. That is, a
null cbmeans publish status updates are posted to the
cb- the publish status update callback. May be
java.lang.IllegalStateException- if this feed is either closed or advertised.
public void advertise()
EPublisher.publishStatus(EFeedState, EPublishFeed)with an
EFeedState.UP uppublish state.
publish(ENotificationMessage)may be called.
public void unadvertise()
public void updateFeedState(EFeedState update)
updateequals the currently stored publish feed state, nothing is done. Otherwise, the updated value is stored. If this feed is advertised to the server and the subscription feed is up, then this update is forwarded to the subject.
update- the new publish feed state.
java.lang.IllegalStateException- if this feed was closed and is inactive or is not advertised.
public void publish(ENotificationMessage msg)
msg- post this message to the subject.
msgmessage key does not match the feed message key.
java.lang.IllegalStateException- if this feed is inactive, not advertised or the publisher has not declared the feed to be up.