Script Valley
Redis: Complete Course
Pub/Sub and Streams/Assessment

Practice & Assessment

Test your understanding of Pub/Sub and Streams

Multiple Choice Questions

5
1

A subscriber disconnects for 30 seconds. Using Redis Pub/Sub, how many messages sent during that time will it receive on reconnect?

2

What does XACK do in a Redis Stream consumer group?

3

Which XREADGROUP argument means 'give me messages not yet delivered to any consumer in my group'?

4

What Redis config must you set to receive key expiry notifications via Pub/Sub?

5

Which messaging pattern guarantees each message is delivered to exactly one consumer?

Coding Challenges

1
1

Real-Time Notification System

Build a simple notification system with two processes: a Publisher that sends a notification (userId, message, timestamp) to a Redis Pub/Sub channel notifications:<userId> every 2 seconds, and a Subscriber that listens on that channel, prints received messages, and stores them in a Redis Stream notifications:log using XADD. After 10 messages, read and print the full stream with XRANGE. Input: none (hardcoded userId). Output: console log of received notifications and stream contents. Estimated time: 25 minutes.

Medium

Mini Project

1

Event-Driven Order Processing Pipeline

Build a simulated order processing system using Redis Streams. Implement: an Order Service that writes order events (orderId, userId, items, total) to a Stream 'orders' using XADD. Create a consumer group 'processors' with two consumers: InventoryConsumer (reads orders, checks a Hash 'inventory:<productId>' for stock, writes to a result Stream 'inventory:results') and BillingConsumer (reads orders, simulates charging by writing to 'billing:results'). Both consumers XACK after processing. Add a monitor script that reads XPENDING every 5 seconds and XCLAIMs entries older than 10 seconds. Demonstrate failed processing by stopping one consumer mid-run and watching the monitor reclaim its messages.

Hard