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"));
}
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"));
}
Aggregations