Redis › Streams
How would you design a robust event sourcing system using Redis Streams as the primary event log?
AdvancedAnswer
You would use a single stream, or several streams organized by event category, as the authoritative append only log of every event that has occurred, use consumer groups to let different services independently process events relevant to them, ensure consumers handle messages idempotently in case of redelivery, and consider periodically trimming very old entries once they are no longer needed for replay purposes.
XADD events '*' type 'OrderCreated' orderId '1001'
XGROUP CREATE events analytics_service '$'
XGROUP CREATE events email_service '$'Real-world example An e-commerce platform uses a single events stream as its source of truth for everything that happens, with separate consumer groups for their analytics service and their email notification service, each independently processing the exact same underlying events at their own pace.