Challenge - 5 Problems
Redis Consumer Groups Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this XREADGROUP command?
Given a Redis stream 'mystream' with messages and a consumer group 'mygroup', what will this command return?
Assume the stream has 5 pending messages for this group and consumer1 has not read any yet.
XREADGROUP GROUP mygroup consumer1 COUNT 2 STREAMS mystream > Assume the stream has 5 pending messages for this group and consumer1 has not read any yet.
Redis
XREADGROUP GROUP mygroup consumer1 COUNT 2 STREAMS mystream >Attempts:
2 left
💡 Hint
The '>' ID in XREADGROUP means to read only new messages never delivered to any consumer in the group.
✗ Incorrect
Using '>' in XREADGROUP returns only new messages that have never been delivered to any consumer in the group. Pending messages are not returned with '>'.
🧠 Conceptual
intermediate1:30remaining
What happens when a consumer acknowledges a message in a consumer group?
In Redis streams, when a consumer calls XACK for a message ID in its consumer group, what is the effect?
Attempts:
2 left
💡 Hint
Think about what 'acknowledging' means in message queue systems.
✗ Incorrect
XACK removes the message ID from the pending entries list of the consumer group, marking it as processed by that consumer.
📝 Syntax
advanced1:30remaining
Which XGROUP command correctly creates a consumer group starting at the beginning of the stream?
You want to create a consumer group named 'group1' on stream 'stream1' starting from the very first message. Which command is correct?
Attempts:
2 left
💡 Hint
The starting ID '0' means from the beginning of the stream.
✗ Incorrect
Using '0' as the ID in XGROUP CREATE means the group will start reading from the first message in the stream.
🔧 Debug
advanced2:00remaining
Why does this XREADGROUP command return no messages?
A consumer runs:
But it returns an empty array even though the stream has messages. Why?
XREADGROUP GROUP mygroup consumer1 COUNT 5 STREAMS mystream 0But it returns an empty array even though the stream has messages. Why?
Redis
XREADGROUP GROUP mygroup consumer1 COUNT 5 STREAMS mystream 0
Attempts:
2 left
💡 Hint
Consider the difference between '>' and a specific ID in XREADGROUP.
✗ Incorrect
Using '0' as the ID in XREADGROUP reads only pending messages with IDs greater than 0 assigned to the consumer. If none are pending, it returns empty. To read new messages, use '>'.
❓ optimization
expert3:00remaining
How to efficiently claim pending messages from a failed consumer?
In a Redis consumer group, consumer 'A' crashed leaving 100 pending messages. You want consumer 'B' to claim all messages pending for 'A' that are idle for more than 5 minutes. Which command achieves this efficiently?
Attempts:
2 left
💡 Hint
You need to find the IDs first, then claim them.
✗ Incorrect
XPENDING with range and consumer filters returns the IDs of pending messages for consumer 'A' idle over 5 minutes (300000 ms). Then XCLAIM claims those IDs for consumer 'B'.