Package org.redisson
Class RedissonTopic
java.lang.Object
org.redisson.RedissonTopic
- All Implemented Interfaces:
RTopic
,RTopicAsync
- Direct Known Subclasses:
RedissonShardedTopic
Distributed topic implementation. Messages are delivered to all message listeners across Redis cluster.
- Author:
- Nikita Koksharov
-
Constructor Summary
ConstructorDescriptionRedissonTopic
(Codec codec, CommandAsyncExecutor commandExecutor, String name) RedissonTopic
(Codec codec, CommandAsyncExecutor commandExecutor, NameMapper nameMapper, String name) RedissonTopic
(CommandAsyncExecutor commandExecutor, String name) -
Method Summary
Modifier and TypeMethodDescription<M> int
addListener
(Class<M> type, MessageListener<? extends M> listener) Subscribes to this topic.int
addListener
(StatusListener listener) Subscribes to status changes of this topicaddListenerAsync
(Class<M> type, MessageListener<? extends M> listener) Subscribes to this topic.addListenerAsync
(StatusListener listener) Subscribes to status changes of this topicaddListenerAsync
(RedisPubSubListener<?> pubSubListener) int
Returns amount of registered listeners to this topiclong
Returns amount of subscribers to this topic across all Redisson instances.Returns amount of subscribers to this topic across all Redisson instances.static RedissonTopic
createRaw
(Codec codec, CommandAsyncExecutor commandExecutor, String name) static RedissonTopic
createRaw
(CommandAsyncExecutor commandExecutor, String name) Get topic channel namesprotected String
getName()
protected String
long
Publish the message to all subscribers of this topicpublishAsync
(Object message) Publish the message to all subscribers of this topic asynchronouslyvoid
Removes all listeners from this topicRemoves all listeners from this topicvoid
removeListener
(Integer... listenerIds) Removes the listener byid
for listening this topicvoid
removeListener
(MessageListener<?> listener) Removes the listener by its instanceremoveListenerAsync
(Integer... listenerIds) Removes the listener byid
for listening this topicremoveListenerAsync
(MessageListener<?> listener) Removes the listener by its instance
-
Constructor Details
-
RedissonTopic
-
RedissonTopic
-
RedissonTopic
public RedissonTopic(Codec codec, CommandAsyncExecutor commandExecutor, NameMapper nameMapper, String name)
-
-
Method Details
-
createRaw
-
createRaw
public static RedissonTopic createRaw(Codec codec, CommandAsyncExecutor commandExecutor, String name) -
getChannelNames
Description copied from interface:RTopic
Get topic channel names- Specified by:
getChannelNames
in interfaceRTopic
- Returns:
- channel names
-
publish
Description copied from interface:RTopic
Publish the message to all subscribers of this topic -
getName
-
getName
-
publishAsync
Description copied from interface:RTopicAsync
Publish the message to all subscribers of this topic asynchronously- Specified by:
publishAsync
in interfaceRTopicAsync
- Parameters:
message
- to send- Returns:
- number of clients that received the message
-
addListener
Description copied from interface:RTopic
Subscribes to status changes of this topic- Specified by:
addListener
in interfaceRTopic
- Parameters:
listener
- for messages- Returns:
- listener id
- See Also:
-
addListener
Description copied from interface:RTopic
Subscribes to this topic.MessageListener.onMessage
is called when any message is published on this topic.- Specified by:
addListener
in interfaceRTopic
- Type Parameters:
M
- - type of message- Parameters:
type
- - type of messagelistener
- for messages- Returns:
- locally unique listener id
- See Also:
-
addListenerAsync
Description copied from interface:RTopicAsync
Subscribes to status changes of this topic- Specified by:
addListenerAsync
in interfaceRTopicAsync
- Parameters:
listener
- for messages- Returns:
- listener id
- See Also:
-
addListenerAsync
Description copied from interface:RTopicAsync
Subscribes to this topic.MessageListener.onMessage
is called when any message is published on this topic.- Specified by:
addListenerAsync
in interfaceRTopicAsync
- Type Parameters:
M
- type of message- Parameters:
type
- - type of messagelistener
- for messages- Returns:
- locally unique listener id
- See Also:
-
addListenerAsync
-
removeAllListeners
public void removeAllListeners()Description copied from interface:RTopic
Removes all listeners from this topic- Specified by:
removeAllListeners
in interfaceRTopic
-
removeAllListenersAsync
Description copied from interface:RTopicAsync
Removes all listeners from this topic- Specified by:
removeAllListenersAsync
in interfaceRTopicAsync
- Returns:
- void
-
removeListener
Description copied from interface:RTopic
Removes the listener by its instance- Specified by:
removeListener
in interfaceRTopic
- Parameters:
listener
- - listener instance
-
removeListenerAsync
Description copied from interface:RTopicAsync
Removes the listener by its instance- Specified by:
removeListenerAsync
in interfaceRTopicAsync
- Parameters:
listener
- - listener instance- Returns:
- void
-
removeListenerAsync
Description copied from interface:RTopicAsync
Removes the listener byid
for listening this topic- Specified by:
removeListenerAsync
in interfaceRTopicAsync
- Parameters:
listenerIds
- - listener ids- Returns:
- void
-
removeListener
Description copied from interface:RTopic
Removes the listener byid
for listening this topic- Specified by:
removeListener
in interfaceRTopic
- Parameters:
listenerIds
- - listener ids
-
countListeners
public int countListeners()Description copied from interface:RTopic
Returns amount of registered listeners to this topic- Specified by:
countListeners
in interfaceRTopic
- Returns:
- amount of listeners
-
countSubscribersAsync
Description copied from interface:RTopicAsync
Returns amount of subscribers to this topic across all Redisson instances. Each subscriber may have multiple listeners.- Specified by:
countSubscribersAsync
in interfaceRTopicAsync
- Returns:
- amount of subscribers
-
countSubscribers
public long countSubscribers()Description copied from interface:RTopic
Returns amount of subscribers to this topic across all Redisson instances. Each subscriber may have multiple listeners.- Specified by:
countSubscribers
in interfaceRTopic
- Returns:
- amount of subscribers
-