I am using Redis as message broker in pubsub mode.
There are only 1 publisher and N subscribers listening to same channel.
For the original pubsub mode, these N subscribers will receive "same" message each time.
My questions is, is there any mechanism inside Redis or any other ways for these subscribers get different messages for each one ?
2
Answers
You have two choices:
Add messages to a Redis list, and multiple consumers use
BLPOP
and related commands to consume these messages.Add messages to Redis Stream, and multiple consumers use
XREAD
and related commands to consume these messages.thanks for the suggestion using RSMQ https://www.npmjs.com/package/rsmq may do the trick. Its correct tonyc. Just now I used it and it seems like can works fine. Replicated nodejs service app able to handle if both receive the message then justonly one service handle the process.