public interface ESubscriber extends EObject
ESubscribeFeed
using a
ESubscribeFeed.Builder
instance (acquired by calling
ESubscribeFeed.builder()
) and
subscribes
to the
notification. eBus calls
feedStatus(EFeedState, IESubscribeFeed)
to inform the
subscriber about whether the notification feed is
up
or down
. If
down, then the subscriber will not receive calls to
notify(ENotificationMessage, IESubscribeFeed)
until
the feed comes back up. If up, then subscriber may receive
notifications depending on whether the publisher(s) send any
messages. When a subscriber shuts down, it should
unsubscribe
or
close
the feed. If the subscriber does
not do this, eBus will automatically retract the subscription
when it detects the subscriber is finalized.
As of eBus v. 4.2.0, implementing the interface methods is no
longer necessary. Instead, Java lambda expressions may be used
to handle subscriber callbacks. This is done by calling
ESubscribeFeed.Builder.statusCallback(FeedStatusCallback)
and/or
ESubscribeFeed.Builder.notifyCallback(NotifyCallback)
passing in a lambda expression to specify the callback target.
Still, the application must either override EReplier
interface methods or put callbacks in place. Failure
to do either results in ESubscribeFeed.subscribe()
failing. A class wishing to subscribe to notification
messages must still implement ESubscriber
even though
it is no longer necessary to override the interface methods.
It is possible to mix and match ESubscriber
overrides
and callbacks. That is, a notify callback can be used in
conjunction with a
feedStatus(EFeedState, IESubscribeFeed)
override.
ENotifySubject
,
EPublisher
,
ESubscribeFeed
,
ENotificationMessage
,
IESubscribeFeed
NAME_NOT_SET
Modifier and Type | Method and Description |
---|---|
default void |
feedStatus(EFeedState feedState,
IESubscribeFeed feed)
|
default void |
notify(ENotificationMessage msg,
IESubscribeFeed feed)
An incoming notification message from
feed . |
default void feedStatus(EFeedState feedState, IESubscribeFeed feed)
up
or down
.
If down, then
notify(ENotificationMessage, IESubscribeFeed)
will
not be called until the feed comes back up. If up, then
the subscriber will receive all notifications published on
feed
until the subscription is retracted or the
feed goes down.feedState
- the subscription's new feed state.feed
- the status applies to this feed.java.lang.UnsupportedOperationException
- if implementing class does not override this method nor
uses a callback.notify(ENotificationMessage, IESubscribeFeed)
default void notify(ENotificationMessage msg, IESubscribeFeed feed)
feed
.msg
- eBus notification message.feed
- the associated subscription feed.java.lang.UnsupportedOperationException
- if implementing class does not override this method nor
uses a callback.feedStatus(EFeedState, IESubscribeFeed)
Copyright © 2001 - 2024. Charles W. Rapp. All rights reserved.