Package org.redisson
Class RedissonTopic<M>
- java.lang.Object
-
- org.redisson.RedissonTopic<M>
-
- Type Parameters:
M
- message
- All Implemented Interfaces:
RTopic<M>
,RTopicAsync<M>
public class RedissonTopic<M> extends Object implements RTopic<M>
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)
int
addListener(MessageListener<M> listener)
Subscribes to this topic.int
addListener(StatusListener listener)
Subscribes to status changes of this topicRFuture<Integer>
addListenerAsync(MessageListener<M> listener)
Subscribes to this topic.RFuture<Integer>
addListenerAsync(RedisPubSubListener<?> pubSubListener)
protected io.netty.buffer.ByteBuf
encode(Object value)
List<String>
getChannelNames()
Get topic channel nameslong
publish(M message)
Publish the message to all subscribers of this topicRFuture<Long>
publishAsync(M 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 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<M>
- Returns:
- channel names
-
publish
public long publish(M message)
Description copied from interface:RTopic
Publish the message to all subscribers of this topic
-
publishAsync
public RFuture<Long> publishAsync(M message)
Description copied from interface:RTopicAsync
Publish the message to all subscribers of this topic asynchronously- Specified by:
publishAsync
in interfaceRTopicAsync<M>
- 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<M>
- Parameters:
listener
- for messages- Returns:
- listener id
- See Also:
StatusListener
-
addListener
public int addListener(MessageListener<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<M>
- Parameters:
listener
- for messages- Returns:
- locally unique listener id
- See Also:
MessageListener
-
addListenerAsync
public RFuture<Integer> addListenerAsync(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<M>
- Parameters:
listener
- for messages- Returns:
- locally unique listener id
- See Also:
MessageListener
-
addListenerAsync
public RFuture<Integer> addListenerAsync(RedisPubSubListener<?> pubSubListener)
-
removeAllListeners
public void removeAllListeners()
Description copied from interface:RTopic
Removes all listeners from this topic- Specified by:
removeAllListeners
in interfaceRTopic<M>
-
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<M>
- Parameters:
listener
- - listener instance
-
removeListener
public void removeListener(int listenerId)
Description copied from interface:RTopic
Removes the listener byid
for listening this topic- Specified by:
removeListener
in interfaceRTopic<M>
- Parameters:
listenerId
- - listener id
-
-