Search in sources :

Example 11 with MessageListener

use of org.redisson.api.listener.MessageListener in project redisson by redisson.

the class RedissonTopicReactiveTest method testRemoveListenerByInstance.

@Test
public void testRemoveListenerByInstance() throws InterruptedException {
    RTopicReactive topic1 = redisson.getTopic("topic1");
    MessageListener listener = new MessageListener() {

        @Override
        public void onMessage(CharSequence channel, Object msg) {
            Assertions.fail();
        }
    };
    topic1.addListener(Message.class, listener).block();
    topic1 = redisson.getTopic("topic1");
    topic1.removeListener(listener);
    topic1.publish(new Message("123"));
}
Also used : MessageListener(org.redisson.api.listener.MessageListener) RTopicReactive(org.redisson.api.RTopicReactive) Test(org.junit.jupiter.api.Test)

Example 12 with MessageListener

use of org.redisson.api.listener.MessageListener in project redisson by redisson.

the class RedissonTopicRxTest method testRemoveListenerById.

@Test
public void testRemoveListenerById() throws InterruptedException {
    RTopicRx topic1 = redisson.getTopic("topic1");
    MessageListener listener = new MessageListener() {

        @Override
        public void onMessage(CharSequence channel, Object msg) {
            Assertions.fail();
        }
    };
    Single<Integer> res = topic1.addListener(Message.class, listener);
    Integer listenerId = res.blockingGet();
    topic1 = redisson.getTopic("topic1");
    topic1.removeListener(listenerId);
    topic1.publish(new Message("123"));
}
Also used : RTopicRx(org.redisson.api.RTopicRx) MessageListener(org.redisson.api.listener.MessageListener) Test(org.junit.jupiter.api.Test)

Aggregations

MessageListener (org.redisson.api.listener.MessageListener)12 Test (org.junit.jupiter.api.Test)4 RTopic (org.redisson.api.RTopic)4 IOException (java.io.IOException)3 RedissonClient (org.redisson.api.RedissonClient)3 CompositeCodec (org.redisson.codec.CompositeCodec)3 File (java.io.File)2 java.util (java.util)2 HttpSession (javax.servlet.http.HttpSession)2 org.apache.catalina (org.apache.catalina)2 ManagerBase (org.apache.catalina.session.ManagerBase)2 Log (org.apache.juli.logging.Log)2 LogFactory (org.apache.juli.logging.LogFactory)2 Redisson (org.redisson.Redisson)2 RMap (org.redisson.api.RMap)2 RSet (org.redisson.api.RSet)2 RTopicReactive (org.redisson.api.RTopicReactive)2 RTopicRx (org.redisson.api.RTopicRx)2 BaseStatusListener (org.redisson.api.listener.BaseStatusListener)2 Codec (org.redisson.client.codec.Codec)2