0
0
Redisquery~20 mins

XREADGROUP for consumer groups in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Stream Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Output of XREADGROUP with new consumer
Given a Redis stream 'mystream' with entries and a consumer group 'mygroup', what will be the output of this command?
XREADGROUP GROUP mygroup consumer1 COUNT 2 STREAMS mystream > 
Redis
XREADGROUP GROUP mygroup consumer1 COUNT 2 STREAMS mystream >
A[["mystream", [["0-0", {"field1": "value1"}]]]]
B[]
C[["mystream", [["1609459200000-0", {"field1": "value1"}], ["1609459200001-0", {"field2": "value2"}]]]]
D[["mystream", [[">", {"field1": "value1"}]]]]
Attempts:
2 left
💡 Hint
The '>' ID in XREADGROUP returns only new messages never delivered to any consumer in the group.
🧠 Conceptual
intermediate
2:00remaining
Behavior of XREADGROUP with ID '0'
What happens when you run the following command for a consumer group that already exists?
XREADGROUP GROUP mygroup consumer2 STREAMS mystream 0
AReturns no messages because '0' is invalid for XREADGROUP.
BReturns only new messages never delivered to any consumer.
CReturns only pending messages for consumer2.
DReturns all messages in the stream, including those already delivered to other consumers.
Attempts:
2 left
💡 Hint
Using '0' as the ID in XREADGROUP means to read from the beginning of the stream.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in XREADGROUP command
Which of the following XREADGROUP commands has a syntax error?
AXREADGROUP GROUP mygroup consumer1 STREAMS mystream > COUNT 5
BXREADGROUP GROUP mygroup consumer1 COUNT 5 STREAMS mystream >
CXREADGROUP GROUP mygroup consumer1 STREAMS mystream 0
DXREADGROUP GROUP mygroup consumer1 COUNT 10 STREAMS mystream 0
Attempts:
2 left
💡 Hint
The COUNT option must appear before STREAMS and stream keys.
optimization
advanced
2:00remaining
Optimizing XREADGROUP for multiple streams
You want to read new messages from two streams 'stream1' and 'stream2' for consumer 'c1' in group 'g1'. Which command efficiently reads only new messages from both streams?
AXREADGROUP GROUP g1 c1 STREAMS stream1 stream2 0 0
BXREADGROUP GROUP g1 c1 COUNT 10 STREAMS stream1 stream2 > >
CXREADGROUP GROUP g1 c1 COUNT 10 STREAMS stream1 stream2 0 0
DXREADGROUP GROUP g1 c1 STREAMS stream1 stream2 > >
Attempts:
2 left
💡 Hint
Use '>' to read only new messages never delivered to any consumer in the group.
🔧 Debug
expert
2:00remaining
Why does XREADGROUP return no messages?
A consumer group 'g1' exists on stream 'mystream'. Consumer 'c1' runs:
XREADGROUP GROUP g1 c1 STREAMS mystream > COUNT 5

But it returns an empty array even though the stream has new messages. What is the most likely cause?
AThe consumer group was created with an ID higher than the new messages' IDs.
BThe COUNT option is too low to return any messages.
CThe stream 'mystream' is empty.
DThe consumer name 'c1' is not registered in the group.
Attempts:
2 left
💡 Hint
The group ID determines which messages are considered new for '>' reads.