Redis › Streams

How would you handle a message that was delivered to a consumer but never acknowledged, perhaps because that consumer crashed while processing it?

Advanced

Answer

You use the XPENDING command to identify messages that have been delivered but not yet acknowledged, and XCLAIM to transfer ownership of a specific pending message to a different, healthy consumer after enough time has passed, ensuring that a crashed worker's unfinished work is not permanently lost and can be picked up by another available consumer.
XPENDING orders processing_group
XCLAIM orders processing_group worker2 60000 1725800000-0
Real-world example A monitoring process periodically checks for messages that have been pending for too long using XPENDING, automatically reclaiming them with XCLAIM and assigning them to a healthy worker whenever the original consumer appears to have crashed.

Common follow-ups: How long should you typically wait before claiming a pending message from another consumer?;What happens if the original consumer eventually does complete and try to acknowledge a message that has already been claimed?