E
- event type@FunctionalInterface public interface Subscriber<E> extends BaseSubscriber, Consumer<E>, HasUsingMessage<E>
Waring: Subscribers cannot modify its underlying asset using the same thread that was used for calling the Subscriber. For example, a Subscriber to a MapView must not update the MapView itself in the same thread.
Modifier and Type | Method and Description |
---|---|
default void |
accept(E e) |
static <M> SubscriberBuilder<M> |
builder(Class<M> messageClassToken)
Creates and returns a new SubscriberBuilder that can be used
to configure and build new Subscribers.
|
static <E> Subscriber<E> |
indexAware(@NotNull Subscriber<E> subscriber)
Ensures that the provided
subscriber is index aware, if it is,
returns the provided subscriber
or else
creates and returns a new Subscriber that wraps the
provided subscriber and that implements the methods BaseSubscriber.index() ,
and BaseSubscriber.index(long) . |
default void |
onEndOfBootStrap()
This method is optionally invoked by Datagrid upon
end of bootstrapping.
|
void |
onMessage(E e)
This method is invoked by DataGrid when there is a new unseen event.
|
index, index, isIndexAware, isTcpBufferFullEnough, onEndOfSubscription
usingMessage
void onMessage(E e) throws InvalidSubscriberException
e
- eventInvalidSubscriberException
- is thrown if this subscriber is no longer valid.default void onEndOfBootStrap()
Currently, only a TopologySubscription
support this call-back.
static <E> Subscriber<E> indexAware(@NotNull @NotNull Subscriber<E> subscriber)
subscriber
is index aware, if it is,
returns the provided subscriber
or else
creates and returns a new Subscriber
that wraps the
provided subscriber
and that implements the methods BaseSubscriber.index()
,
and BaseSubscriber.index(long)
.
An index aware TopicSubscriber keeps track of its last known index, allowing a subscriber to be seamlessly handed over between servers.
E
- message typesubscriber
- to wrapSubscriber
that wraps the
provided topicSubscriber
and that implements the methods BaseSubscriber.index()
,
and BaseSubscriber.index(long)
static <M> SubscriberBuilder<M> builder(Class<M> messageClassToken)
M
- message typemessageClassToken
- representing the message typeCopyright © 2021. All rights reserved.