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(CommandAsyncExecutor commandExecutor, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
acquire(AsyncSemaphore semaphore)
<M> int
addListener(Class<M> type, MessageListener<? extends M> listener)
Subscribes to this topic.int
addListener(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 topicint
countListeners()
Returns amount of registered listenersprotected io.netty.buffer.ByteBuf
encode(Object value)
List<String>
getChannelNames()
Get topic channel nameslong
publish(Object message)
Publish the message to all subscribers of this topicRFuture<Long>
publishAsync(Object message)
Publish the message to all subscribers of this topic asynchronouslyvoid
removeAllListeners()
Removes all listeners from this topicvoid
removeListener(int listenerId)
Removes the listener byid
for listening this topicvoid
removeListener(MessageListener<?> listener)
Removes the listener by its instanceRFuture<Void>
removeListenerAsync(int listenerId)
Removes the listener byid
for 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)
-
-
Method Detail
-
getChannelNames
public List<String> getChannelNames()
Description copied from interface:RTopic
Get topic channel names- Specified by:
getChannelNames
in interfaceRTopic
- Returns:
- channel names
-
publish
public long publish(Object message)
Description copied from interface:RTopic
Publish the message to all subscribers of this topic
-
publishAsync
public RFuture<Long> publishAsync(Object message)
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
-
encode
protected io.netty.buffer.ByteBuf encode(Object value)
-
addListener
public int addListener(StatusListener listener)
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:
StatusListener
-
addListener
public <M> int addListener(Class<M> type, MessageListener<? extends M> listener)
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:
MessageListener
-
addListenerAsync
public RFuture<Integer> addListenerAsync(StatusListener listener)
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:
StatusListener
-
addListenerAsync
public <M> RFuture<Integer> addListenerAsync(Class<M> type, MessageListener<M> listener)
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:
MessageListener
-
removeAllListeners
public void removeAllListeners()
Description copied from interface:RTopic
Removes all listeners from this topic- Specified by:
removeAllListeners
in interfaceRTopic
-
acquire
protected void acquire(AsyncSemaphore semaphore)
-
removeListener
public void removeListener(MessageListener<?> listener)
Description copied from interface:RTopic
Removes the listener by its instance- Specified by:
removeListener
in interfaceRTopic
- Parameters:
listener
- - listener instance
-
removeListenerAsync
public RFuture<Void> removeListenerAsync(MessageListener<?> listener)
Description copied from interface:RTopicAsync
Removes the listener by its instance- Specified by:
removeListenerAsync
in interfaceRTopicAsync
- Parameters:
listener
- - listener instance- Returns:
- void
-
removeListenerAsync
public RFuture<Void> removeListenerAsync(int listenerId)
Description copied from interface:RTopicAsync
Removes the listener byid
for listening this topic- Specified by:
removeListenerAsync
in interfaceRTopicAsync
- Parameters:
listenerId
- - listener id- Returns:
- void
-
removeListener
public void removeListener(int listenerId)
Description copied from interface:RTopic
Removes the listener byid
for listening this topic- Specified by:
removeListener
in interfaceRTopic
- Parameters:
listenerId
- - listener id
-
countListeners
public int countListeners()
Description copied from interface:RTopic
Returns amount of registered listeners- Specified by:
countListeners
in interfaceRTopic
- Returns:
- amount of listeners
-
-