skip to Main Content

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


  1. You have two choices:

    1. Add messages to a Redis list, and multiple consumers use BLPOP and related commands to consume these messages.

    2. Add messages to Redis Stream, and multiple consumers use XREAD and related commands to consume these messages.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search