0
0
Redisquery~5 mins

XACK for acknowledging messages in Redis

Choose your learning style9 modes available
Introduction
XACK is used to tell Redis that a message from a stream was processed successfully. This helps keep track of which messages are done and which still need attention.
When you read messages from a Redis stream and want to mark them as handled.
When you want to avoid processing the same message multiple times.
When you use consumer groups to share work and need to confirm message completion.
When you want to clean up pending messages after processing.
When you want to monitor which messages are still waiting to be processed.
Syntax
Redis
XACK <stream> <group> <id> [<id> ...]
Replace with the name of your Redis stream.
Replace with your consumer group name.
Provide one or more message IDs to acknowledge.
Examples
Acknowledge a single message with ID 1526985058136-0 in the group 'mygroup' on stream 'mystream'.
Redis
XACK mystream mygroup 1526985058136-0
Acknowledge two messages at once by listing both IDs.
Redis
XACK mystream mygroup 1526985058136-0 1526985058137-0
Sample Program
This example creates a group, adds a message, reads it as a consumer, then acknowledges it using XACK.
Redis
XGROUP CREATE mystream mygroup $ MKSTREAM
XADD mystream * sensor-id 1234 temperature 19.8
XREADGROUP GROUP mygroup consumer1 COUNT 1 STREAMS mystream >
XACK mystream mygroup 1526985058136-0
OutputSuccess
Important Notes
XACK returns the number of messages it successfully acknowledged.
If you acknowledge a message ID that does not exist or is not pending, it returns 0 for that ID.
Always acknowledge messages after processing to avoid duplicates.
Summary
XACK marks messages as processed in Redis streams.
It helps manage message delivery and avoid reprocessing.
Use it with consumer groups to track message status.