Package org.redisson

Class 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
    • Method Detail

      • getChannelNames

        public List<String> getChannelNames()
        Description copied from interface: RTopic
        Get topic channel names
        Specified by:
        getChannelNames in interface RTopic
        Returns:
        channel names
      • publish

        public long publish(Object message)
        Description copied from interface: RTopic
        Publish the message to all subscribers of this topic
        Specified by:
        publish in interface RTopic
        Parameters:
        message - to send
        Returns:
        the number of clients that received the message
      • getName

        protected String getName()
      • 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 interface RTopicAsync
        Parameters:
        message - to send
        Returns:
        number of clients that received the message
      • addListener

        public int addListener(StatusListener listener)
        Description copied from interface: RTopic
        Subscribes to status changes of this topic
        Specified by:
        addListener in interface RTopic
        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 interface RTopic
        Type Parameters:
        M - - type of message
        Parameters:
        type - - type of message
        listener - for messages
        Returns:
        locally unique listener id
        See Also:
        MessageListener
      • 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 interface RTopicAsync
        Type Parameters:
        M - type of message
        Parameters:
        type - - type of message
        listener - 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 interface RTopic
      • removeListener

        public void removeListener(MessageListener<?> listener)
        Description copied from interface: RTopic
        Removes the listener by its instance
        Specified by:
        removeListener in interface RTopic
        Parameters:
        listener - - listener instance
      • removeListenerAsync

        public RFuture<Void> removeListenerAsync(Integer... listenerIds)
        Description copied from interface: RTopicAsync
        Removes the listener by id for listening this topic
        Specified by:
        removeListenerAsync in interface RTopicAsync
        Parameters:
        listenerIds - - listener ids
        Returns:
        void
      • removeListener

        public void removeListener(Integer... listenerIds)
        Description copied from interface: RTopic
        Removes the listener by id for listening this topic
        Specified by:
        removeListener in interface RTopic
        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 interface RTopic
        Returns:
        amount of listeners
      • countSubscribersAsync

        public RFuture<Long> 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 interface RTopicAsync
        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 interface RTopic
        Returns:
        amount of subscribers