1

I handle events from Redis with 3 machine. But I don't want that if any events handle by x machine, other machines won't handle it.

I work on nodejs. I use subscribe method for handling.

Redis.psubscribe('__keyevent@0__:incrby...

I see How to make sure my event is handled by only one instance of my app? and Competing Consumer on Redis Pub/Sub supported?, but they are really old. There may be better way.

yellowpisagor
  • 146
  • 3
  • 13

1 Answers1

2

Redis pubsub isn't designed for such a use case. What you want can be achieved by using Redis Streams. It's released as part of Redis 5.0 a few days back. You can have 3 consumers (1 consumer per instance/machine) as part of the same consumer group which reads from a Redis stream. Redis will make sure the 3 consumers get distinct messages from the same stream.

Community
  • 1
  • 1
rainhacker
  • 592
  • 2
  • 13