use of org.redisson.api.listener.PatternStatusListener in project redisson by redisson.
the class RedissonTopicPatternTest method testConcurrentTopic.
@Test
public void testConcurrentTopic() throws Exception {
Config config = BaseTest.createConfig();
RedissonClient redisson = Redisson.create(config);
int threads = 30;
int loops = 50000;
ExecutorService executor = Executors.newFixedThreadPool(threads);
List<Future<?>> futures = new ArrayList<>();
for (int i = 0; i < threads; i++) {
Runnable worker = new Runnable() {
@Override
public void run() {
for (int j = 0; j < loops; j++) {
RPatternTopic<String> t = redisson.getPatternTopic("PUBSUB*");
int listenerId = t.addListener(new PatternStatusListener() {
@Override
public void onPUnsubscribe(String channel) {
}
@Override
public void onPSubscribe(String channel) {
}
});
redisson.getTopic("PUBSUB_" + j).publish("message");
t.removeListener(listenerId);
}
}
};
Future<?> s = executor.submit(worker);
futures.add(s);
}
executor.shutdown();
Assert.assertTrue(executor.awaitTermination(threads * loops * 1000, TimeUnit.SECONDS));
for (Future<?> future : futures) {
future.get();
}
redisson.shutdown();
}
Aggregations