use of org.redisson.api.RTopicReactive in project redisson by redisson.
the class RedissonTopicReactiveTest method testRemoveListenerById.
@Test
public void testRemoveListenerById() throws InterruptedException {
RTopicReactive topic1 = redisson.getTopic("topic1");
MessageListener listener = new MessageListener() {
@Override
public void onMessage(CharSequence channel, Object msg) {
Assertions.fail();
}
};
Mono<Integer> res = topic1.addListener(Message.class, listener);
Integer listenerId = res.block();
topic1 = redisson.getTopic("topic1");
topic1.removeListener(listenerId);
topic1.publish(new Message("123"));
}
use of org.redisson.api.RTopicReactive in project redisson by redisson.
the class RedissonTopicReactiveTest method testLong.
@Test
public void testLong() throws InterruptedException {
RTopicReactive topic = redisson.getTopic("test");
Flux<String> messages = topic.getMessages(String.class);
List<String> list = new ArrayList<>();
messages.subscribe(new Subscriber<String>() {
@Override
public void onSubscribe(Subscription s) {
s.request(10);
}
@Override
public void onNext(String t) {
list.add(t);
}
@Override
public void onError(Throwable t) {
}
@Override
public void onComplete() {
}
});
for (int i = 0; i < 15; i++) {
sync(topic.publish("" + i));
}
assertThat(list).containsExactly("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
}
use of org.redisson.api.RTopicReactive 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"));
}
Aggregations