Search code examples
redisconsumerredis-streams

How does COUNT work with multiple streams in XREADGROUP?


I want to use the Redis XREADGROUP command to consume messages from multiple Redis streams. What does the COUNT parameter mean in such cases (i.e. is it the total number of messages, or a number of messages per stream)? Also, is it possible to read exactly one message with this scenario?


Solution

  • COUNT is the maximum number of elements per stream. The XREADGROUP command is a special version of the XREAD command with support for consumer groups. So the documentation for XREAD applies.

    You can set COUNT as 1, then you'll get up to 1 element per stream in the command.

    If you don't set COUNT, you get all messages available per stream.