Package org.redisson.api
Interface RTopic
-
- All Superinterfaces:
RTopicAsync
- All Known Implementing Classes:
RedissonTopic
public interface RTopic extends RTopicAsync
Distributed topic. Messages are delivered to all message listeners across Redis cluster.- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <M> int
addListener(Class<M> type, MessageListener<? extends M> listener)
Subscribes to this topic.int
addListener(StatusListener listener)
Subscribes to status changes of this topicint
countListeners()
Returns amount of registered listeners to this topiclong
countSubscribers()
Returns amount of subscribers to this topic across all Redisson instances.List<String>
getChannelNames()
Get topic channel nameslong
publish(Object message)
Publish the message to all subscribers of this topicvoid
removeAllListeners()
Removes all listeners from this topicvoid
removeListener(Integer... listenerIds)
Removes the listener byid
for listening this topicvoid
removeListener(MessageListener<?> listener)
Removes the listener by its instance-
Methods inherited from interface org.redisson.api.RTopicAsync
addListenerAsync, addListenerAsync, countSubscribersAsync, publishAsync, removeListenerAsync, removeListenerAsync
-
-
-
-
Method Detail
-
publish
long publish(Object message)
Publish the message to all subscribers of this topic- Parameters:
message
- to send- Returns:
- the number of clients that received the message
-
addListener
<M> int addListener(Class<M> type, MessageListener<? extends M> listener)
Subscribes to this topic.MessageListener.onMessage
is called when any message is published on this topic.- Type Parameters:
M
- - type of message- Parameters:
type
- - type of messagelistener
- for messages- Returns:
- locally unique listener id
- See Also:
MessageListener
-
addListener
int addListener(StatusListener listener)
Subscribes to status changes of this topic- Parameters:
listener
- for messages- Returns:
- listener id
- See Also:
StatusListener
-
removeListener
void removeListener(MessageListener<?> listener)
Removes the listener by its instance- Parameters:
listener
- - listener instance
-
removeListener
void removeListener(Integer... listenerIds)
Removes the listener byid
for listening this topic- Parameters:
listenerIds
- - listener ids
-
removeAllListeners
void removeAllListeners()
Removes all listeners from this topic
-
countListeners
int countListeners()
Returns amount of registered listeners to this topic- Returns:
- amount of listeners
-
countSubscribers
long countSubscribers()
Returns amount of subscribers to this topic across all Redisson instances. Each subscriber may have multiple listeners.- Returns:
- amount of subscribers
-
-