Package org.redisson
Class RedissonTopic
- java.lang.Object
-
- org.redisson.RedissonTopic
-
- All Implemented Interfaces:
RTopic,RTopicAsync
public class RedissonTopic extends Object implements RTopic
Distributed topic implementation. Messages are delivered to all message listeners across Redis cluster.- Author:
- Nikita Koksharov
-
-
Constructor Summary
Constructors Constructor Description RedissonTopic(Codec codec, CommandAsyncExecutor commandExecutor, String name)RedissonTopic(Codec codec, CommandAsyncExecutor commandExecutor, NameMapper nameMapper, String name)RedissonTopic(CommandAsyncExecutor commandExecutor, String name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidacquire(AsyncSemaphore semaphore)<M> intaddListener(Class<M> type, MessageListener<? extends M> listener)Subscribes to this topic.intaddListener(StatusListener listener)Subscribes to status changes of this topic<M> RFuture<Integer>addListenerAsync(Class<M> type, MessageListener<M> listener)Subscribes to this topic.RFuture<Integer>addListenerAsync(StatusListener listener)Subscribes to status changes of this topicprotected RFuture<Integer>addListenerAsync(RedisPubSubListener<?> pubSubListener)intcountListeners()Returns amount of registered listeners to this topiclongcountSubscribers()Returns amount of subscribers to this topic across all Redisson instances.RFuture<Long>countSubscribersAsync()Returns amount of subscribers to this topic across all Redisson instances.static RedissonTopiccreateRaw(Codec codec, CommandAsyncExecutor commandExecutor, String name)static RedissonTopiccreateRaw(CommandAsyncExecutor commandExecutor, String name)List<String>getChannelNames()Get topic channel namesprotected StringgetName()protected StringgetName(Object o)longpublish(Object message)Publish the message to all subscribers of this topicRFuture<Long>publishAsync(Object message)Publish the message to all subscribers of this topic asynchronouslyvoidremoveAllListeners()Removes all listeners from this topicvoidremoveListener(Integer... listenerIds)Removes the listener byidfor listening this topicvoidremoveListener(MessageListener<?> listener)Removes the listener by its instanceRFuture<Void>removeListenerAsync(Integer... listenerIds)Removes the listener byidfor listening this topicRFuture<Void>removeListenerAsync(MessageListener<?> listener)Removes the listener by its instance
-
-
-
Constructor Detail
-
RedissonTopic
public RedissonTopic(CommandAsyncExecutor commandExecutor, String name)
-
RedissonTopic
public RedissonTopic(Codec codec, CommandAsyncExecutor commandExecutor, String name)
-
RedissonTopic
public RedissonTopic(Codec codec, CommandAsyncExecutor commandExecutor, NameMapper nameMapper, String name)
-
-
Method Detail
-
createRaw
public static RedissonTopic createRaw(CommandAsyncExecutor commandExecutor, String name)
-
createRaw
public static RedissonTopic createRaw(Codec codec, CommandAsyncExecutor commandExecutor, String name)
-
getChannelNames
public List<String> getChannelNames()
Description copied from interface:RTopicGet topic channel names- Specified by:
getChannelNamesin interfaceRTopic- Returns:
- channel names
-
publish
public long publish(Object message)
Description copied from interface:RTopicPublish the message to all subscribers of this topic
-
getName
protected String getName()
-
publishAsync
public RFuture<Long> publishAsync(Object message)
Description copied from interface:RTopicAsyncPublish the message to all subscribers of this topic asynchronously- Specified by:
publishAsyncin interfaceRTopicAsync- Parameters:
message- to send- Returns:
- number of clients that received the message
-
addListener
public int addListener(StatusListener listener)
Description copied from interface:RTopicSubscribes to status changes of this topic- Specified by:
addListenerin interfaceRTopic- Parameters:
listener- for messages- Returns:
- listener id
- See Also:
StatusListener
-
addListener
public <M> int addListener(Class<M> type, MessageListener<? extends M> listener)
Description copied from interface:RTopicSubscribes to this topic.MessageListener.onMessageis called when any message is published on this topic.- Specified by:
addListenerin interfaceRTopic- Type Parameters:
M- - type of message- Parameters:
type- - type of messagelistener- for messages- Returns:
- locally unique listener id
- See Also:
MessageListener
-
addListenerAsync
public RFuture<Integer> addListenerAsync(StatusListener listener)
Description copied from interface:RTopicAsyncSubscribes to status changes of this topic- Specified by:
addListenerAsyncin interfaceRTopicAsync- Parameters:
listener- for messages- Returns:
- listener id
- See Also:
StatusListener
-
addListenerAsync
public <M> RFuture<Integer> addListenerAsync(Class<M> type, MessageListener<M> listener)
Description copied from interface:RTopicAsyncSubscribes to this topic.MessageListener.onMessageis called when any message is published on this topic.- Specified by:
addListenerAsyncin interfaceRTopicAsync- Type Parameters:
M- type of message- Parameters:
type- - type of messagelistener- for messages- Returns:
- locally unique listener id
- See Also:
MessageListener
-
addListenerAsync
protected RFuture<Integer> addListenerAsync(RedisPubSubListener<?> pubSubListener)
-
removeAllListeners
public void removeAllListeners()
Description copied from interface:RTopicRemoves all listeners from this topic- Specified by:
removeAllListenersin interfaceRTopic
-
acquire
protected void acquire(AsyncSemaphore semaphore)
-
removeListener
public void removeListener(MessageListener<?> listener)
Description copied from interface:RTopicRemoves the listener by its instance- Specified by:
removeListenerin interfaceRTopic- Parameters:
listener- - listener instance
-
removeListenerAsync
public RFuture<Void> removeListenerAsync(MessageListener<?> listener)
Description copied from interface:RTopicAsyncRemoves the listener by its instance- Specified by:
removeListenerAsyncin interfaceRTopicAsync- Parameters:
listener- - listener instance- Returns:
- void
-
removeListenerAsync
public RFuture<Void> removeListenerAsync(Integer... listenerIds)
Description copied from interface:RTopicAsyncRemoves the listener byidfor listening this topic- Specified by:
removeListenerAsyncin interfaceRTopicAsync- Parameters:
listenerIds- - listener ids- Returns:
- void
-
removeListener
public void removeListener(Integer... listenerIds)
Description copied from interface:RTopicRemoves the listener byidfor listening this topic- Specified by:
removeListenerin interfaceRTopic- Parameters:
listenerIds- - listener ids
-
countListeners
public int countListeners()
Description copied from interface:RTopicReturns amount of registered listeners to this topic- Specified by:
countListenersin interfaceRTopic- Returns:
- amount of listeners
-
countSubscribersAsync
public RFuture<Long> countSubscribersAsync()
Description copied from interface:RTopicAsyncReturns amount of subscribers to this topic across all Redisson instances. Each subscriber may have multiple listeners.- Specified by:
countSubscribersAsyncin interfaceRTopicAsync- Returns:
- amount of subscribers
-
countSubscribers
public long countSubscribers()
Description copied from interface:RTopicReturns amount of subscribers to this topic across all Redisson instances. Each subscriber may have multiple listeners.- Specified by:
countSubscribersin interfaceRTopic- Returns:
- amount of subscribers
-
-