0
0
Redisquery~20 mins

Consumer groups concept in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Consumer Groups Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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?

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 >
AReturns an empty array because consumer1 has no pending messages.
BReturns the first 2 messages in the stream regardless of delivery status.
CReturns the 2 oldest pending messages assigned to consumer1.
DReturns the next 2 new messages that were never delivered to any consumer in 'mygroup'.
Attempts:
2 left
💡 Hint
The '>' ID in XREADGROUP means to read only new messages never delivered to any consumer in the group.
🧠 Conceptual
intermediate
1: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?
AThe message is removed from the pending entries list for that consumer group.
BThe message is deleted from all consumer groups.
CThe message is removed from the stream permanently.
DThe message is marked as delivered but remains pending.
Attempts:
2 left
💡 Hint
Think about what 'acknowledging' means in message queue systems.
📝 Syntax
advanced
1: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?
AXGROUP CREATE stream1 group1 $
BXGROUP CREATE stream1 group1 0
CXGROUP CREATE stream1 group1 >
DXGROUP CREATE stream1 group1 -
Attempts:
2 left
💡 Hint
The starting ID '0' means from the beginning of the stream.
🔧 Debug
advanced
2:00remaining
Why does this XREADGROUP command return no messages?
A consumer runs:

XREADGROUP GROUP mygroup consumer1 COUNT 5 STREAMS mystream 0

But it returns an empty array even though the stream has messages. Why?
Redis
XREADGROUP GROUP mygroup consumer1 COUNT 5 STREAMS mystream 0
ABecause XREADGROUP with a specific ID reads only new messages with IDs greater than the given ID, but '0' is not valid here.
BBecause XREADGROUP with a specific ID reads only pending messages with IDs greater than the given ID, and '0' excludes all.
CBecause XREADGROUP expects '>' to read new messages; using '0' reads only pending messages, but none are pending for this consumer.
DBecause '0' means read messages with ID greater than 0, but all messages have IDs less than or equal to 0.
Attempts:
2 left
💡 Hint
Consider the difference between '>' and a specific ID in XREADGROUP.
optimization
expert
3: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?
AXPENDING mystream mygroup IDLE 300000 - + 100 A | then XCLAIM mystream mygroup B 300000 <list_of_ids>
BXCLAIM mystream mygroup B 300000 - COUNT 100 IDLE 300000
CXCLAIM mystream mygroup B 300000 - IDLE 300000
DXPENDING mystream mygroup - + 100 B | then XCLAIM mystream mygroup B 300000 <list_of_ids>
Attempts:
2 left
💡 Hint
You need to find the IDs first, then claim them.