You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Dragonfly, as well as in Redis and Valkey, the `XACK` command is used to acknowledge one or more messages in a stream that have been successfully processed.
14
+
It is useful in stream processing systems where consumers must signal that a message has been handled, helping to manage message delivery and retention more efficiently within a consumer group.
15
+
After successfully processing a message, a consumer should call `XACK` to prevent reprocessing and remove the message from the Pending Entries List (PEL).
16
+
11
17
## Syntax
12
18
13
-
XACK key group id [id ... ]
19
+
```shell
20
+
XACK key group id [id ...]
21
+
```
14
22
15
-
**Time complexity:** O(1) for each message ID processed.
23
+
-**Time complexity:** O(1) for each message ID processed.
24
+
-**ACL categories:**@write, @stream, @fast
16
25
17
-
**ACL categories:**@write, @stream, @fast
26
+
## Parameter Explanations
18
27
19
-
**XACK** command acknowledges one or more messages by removing the messages from the pending entries list (PEL) of the specified consumer stream group. A message is pending, and as such stored inside the PEL, when it was delivered to some consumer, normally as a side effect of calling XREADGROUP, or when a consumer took ownership of a message calling XCLAIM. The pending message was delivered to some consumer but the server is yet not sure it was processed at least once. So new calls to XREADGROUP to grab the messages history for a consumer (for instance using an ID of 0), will return such message. Similarly the pending message will be listed by the XPENDING command, that inspects the PEL. Once a consumer successfully processes a message, it should call **XACK** so that such message does not get processed again, and as a side effect, the PEL entry about this message is also purged, releasing memory from the Dragonfly server.
28
+
-`key`: The name of the stream.
29
+
-`group`: The name of the consumer group.
30
+
-`id`: The ID of the message to acknowledge. Multiple IDs can be specified.
20
31
32
+
## Return Values
21
33
22
-
## Return
34
+
- The command returns an integer indicating the number of messages that were successfully acknowledged.
35
+
- Message IDs that are not part of the PEL (i.e., already been acknowledged) will not be considered successful acknowledgments.
36
+
- If the stream or the consumer group does not exist, the command simply returns `0`.
The command returns the number of messages successfully acknowledged. Certain message IDs may no longer be part of the PEL (for example because they have already been acknowledged), and XACK will not count them as successfully acknowledged.
40
+
### Basic Acknowledgement Example
27
41
28
-
## Examples
42
+
Acknowledge a single message that has been processed:
0 commit comments