@FunctionalInterface public interface TopicSubscriber<T,M> extends BaseSubscriber, HasUsingTopic<T>, HasUsingMessage<M>, EndOfConnection
Modifier and Type | Method and Description |
---|---|
static <T,M> TopicSubscriberBuilder<T,M> |
builder(Class<T> topicClassToken,
Class<M> messageClassToken)
Creates and returns a new TopicSubscriberBuilder that can be used
to configure and build new TopicSubscribers.
|
static <T,M> TopicSubscriber<T,M> |
indexAware(@NotNull TopicSubscriber<T,M> topicSubscriber)
Ensures that the provided
topicSubscriber is index aware, if it is,
returns the provided topicSubscriber
or else
creates and returns a new TopicSubscriber that wraps the
provided topicSubscriber and that implements the methods BaseSubscriber.index() ,
and BaseSubscriber.index(long) . |
default void |
onEndOfConnection()
called when the connection is closed
|
void |
onMessage(T topic,
M message)
This method is invoked by DataGrid when a topic in a group has an new message/event
|
index, index, isIndexAware, isTcpBufferFullEnough, onEndOfSubscription
usingTopic
usingMessage
void onMessage(T topic, M message) throws InvalidSubscriberException
topic
- the message was associated withmessage
- publishedInvalidSubscriberException
- is thrown if this subscriber is no longer valid.static <T,M> TopicSubscriber<T,M> indexAware(@NotNull @NotNull TopicSubscriber<T,M> topicSubscriber)
topicSubscriber
is index aware, if it is,
returns the provided topicSubscriber
or else
creates and returns a new TopicSubscriber
that wraps the
provided topicSubscriber
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.
T
- topic typeM
- message typetopicSubscriber
- to wraptopicSubscriber
is index aware, if it is,
returns the provided topicSubscriber
or else
creates and returns a new TopicSubscriber
that wraps the
provided topicSubscriber
and that implements the methods BaseSubscriber.index()
,
and BaseSubscriber.index(long)
static <T,M> TopicSubscriberBuilder<T,M> builder(Class<T> topicClassToken, Class<M> messageClassToken)
M
- message typetopicClassToken
- representing the message typemessageClassToken
- representing the message typedefault void onEndOfConnection()
EndOfConnection
onEndOfConnection
in interface EndOfConnection
Copyright © 2021. All rights reserved.