I have a goal to implement Producer/Consumer pattern using Redisson. Expected behavior is to have multiple producers which emit message to multiple topics and multiple consumers which listen to messages and process them AND each message should be processed only once (only by one of the consumers).
I have tried Pub/Sub, but it doesn't fit the requirements since publishers always broadcast each message.
My current take on the problem is following:
Producer:
client.getBlockingDeque("topic-name").addFirstAsync(messageObj)
Consumer:
executorService.submit(() -> {
var queue = client.getBlockingQueue("topic-name");
try {
while (!Thread.currentThread().isInterrupted()) {
var obj = queue.take();
handle(obj);
}
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
})
What would be the most idiomatic approach to use with Redisson? There is a lot of utilities (RedissonList
/RedissonQueue
/RedissonDeque
/RedissonStream
/etc) and I am just having difficulties choosing one.