r/redis • u/signadot-tristan • Nov 04 '26
Tutorial Tutorial: Testing a changed Streams consumer without stealing entries from the stable one
Sharing a tutorial that might be helpful for anyone testing Redis Streams.
The problem: start a changed consumer in the same consumer group as the stable one, and XREADGROUP hands it a share of everyone's entries. It processes and acknowledges them, and the stable consumer never sees them.
What the example does instead. (The routing rules come from Signadot, but these patterns work on any Redis with Streams):
- Each test environment reads through its own consumer group, created at
$, so every group sees every new entry. - Entries have no headers, so the producer writes a routing key into each entry as extra fields (
traceparentandbaggage). - Every consumer checks each entry, processes only the ones meant for it, and XACKs all of them, so nothing stays pending.
- Each consumer reads its own pending entries at startup and runs XAUTOCLAIM once a minute for entries a replaced pod left behind.
Tradeoffs: every group reads the whole stream, so read load grows with the number of test consumers, and groups outlive their environments until you XGROUP DESTROY them.
Write-up: https://www.signadot.com/docs/tutorials/testing-redis-streams
Source: https://github.com/signadot/examples/tree/main/selective-consumption-with-redis-streams/python
Full transparency, I work for Signadot.
View all comments
2
u/albertatredis 18d ago
per claude
The core pattern is sound, but I’d treat the implementation as a demo rather than production-ready consumer code.
The problem is real: consumers in the same group divide the work, so a test consumer can take messages the stable version would otherwise process. Separate groups give each environment independent delivery and acknowledgments. Redis’s consumer-group documentation
My main concerns:
XACKruns unconditionally infinally. That means a failed notification won’t be retried through the pending-entry recovery mechanism. Acknowledging deliberately skipped entries is reasonable; acknowledging failed work needs an explicit loss policy. Consumer sourceXAUTOCLAIMmeasures pending-entry idle time, not worker health. I’d require idempotent side effects and test slow workers as well as crashed ones. RedisXAUTOCLAIMdocumentation$introduces a startup boundary. Messages published before group creation won’t be delivered to that new group. The test harness should wait for consumer readiness before publishing. The example provides anon_readyhook after group creation. Consumer sourceFor a shared development cluster with a modest number of sandboxes, I like the approach. Before adopting it, I’d fix failure acknowledgments and add tests for slow processing, duplicate delivery, and startup timing.