Skip to content

Commit 8606d6c

Browse files
committed
Docs Originality Update - Batch #9
1 parent b3fb39e commit 8606d6c

11 files changed

+750
-619
lines changed

docs/command-reference/stream/xack.md

+72-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Learn how to use Redis XACK to acknowledge the processing of a message from a stream by a consumer.
2+
description: Learn how to use Redis XACK to acknowledge the processing of a message from a stream by a consumer.
33
---
44

55
import PageTitle from '@site/src/components/PageTitle';
@@ -8,26 +8,87 @@ import PageTitle from '@site/src/components/PageTitle';
88

99
<PageTitle title="Redis XACK Command (Documentation) | Dragonfly" />
1010

11-
## Syntax
11+
## Introduction
12+
13+
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+
This is particularly 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.
1215

13-
XACK key group id [id ... ]
16+
## Syntax
1417

15-
**Time complexity:** O(1) for each message ID processed.
18+
```shell
19+
XACK key group id [id ...]
20+
```
1621

17-
**ACL categories:** @write, @stream, @fast
22+
## Parameter Explanations
1823

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.
24+
- `key`: The name of the stream.
25+
- `group`: The name of the consumer group.
26+
- `id`: The ID of the message to acknowledge. Multiple IDs can be specified.
2027

28+
## Return Values
2129

22-
## Return
30+
The command returns an integer indicating the number of messages that were successfully acknowledged.
2331

24-
[Integer reply](https://redis.io/docs/reference/protocol-spec/#integers), specifically:
32+
## Code Examples
2533

26-
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.
34+
### Basic Acknowledgement Example
2735

28-
## Examples
36+
Acknowledge a single message that has been processed:
2937

3038
```shell
31-
dragonfly> XACK mystream mygroup 1526569495631-0
39+
dragonfly> XADD mystream * name Alice age 30
40+
"1609097574170-0"
41+
dragonfly> XGROUP CREATE mystream mygroup $ MKSTREAM
42+
OK
43+
dragonfly> XREADGROUP GROUP mygroup Alice COUNT 1 STREAMS mystream >
44+
1) 1) "mystream"
45+
2) 1) 1) "1609097574170-0"
46+
2) 1) "name"
47+
2) "Alice"
48+
3) "age"
49+
4) "30"
50+
dragonfly> XACK mystream mygroup 1609097574170-0
3251
(integer) 1
3352
```
53+
54+
### Acknowledging Multiple Messages
55+
56+
Acknowledge multiple messages after processing:
57+
58+
```shell
59+
dragonfly> XADD mystream * name Bob age 25
60+
"1609097574171-0"
61+
dragonfly> XADD mystream * name Charlie age 40
62+
"1609097574172-0"
63+
dragonfly> XACK mystream mygroup 1609097574171-0 1609097574172-0
64+
(integer) 2
65+
```
66+
67+
### Handling Non-existent IDs
68+
69+
Acknowledge attempt on a non-existent message ID:
70+
71+
```shell
72+
dragonfly> XACK mystream mygroup 1609097574173-0
73+
(integer) 0 # No acknowledgment since the ID does not exist.
74+
```
75+
76+
## Best Practices
77+
78+
- Use `XACK` to signal message processing completion to avoid reprocessing.
79+
- Implement proper error handling to manage message IDs that may no longer exist or are not yet acknowledged.
80+
81+
## Common Mistakes
82+
83+
- Not creating a consumer group before attempting to acknowledge messages; `XACK` requires a valid consumer group.
84+
- Attempting to acknowledge messages using IDs that were never read by the group.
85+
86+
## FAQs
87+
88+
### What happens if the message ID is not found?
89+
90+
If the message ID does not exist in the pending entries list of the consumer group, `XACK` returns `0`.
91+
92+
### Can `XACK` be used for automatic acknowledgement?
93+
94+
No, `XACK` requires explicit calls to acknowledge messages after successful processing by consumers.
+66-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Learn how to use Redis XINFO GROUPS to get information about consumer groups of a stream.
2+
description: Learn how to use Redis XINFO GROUPS to get information about consumer groups of a stream.
33
---
44

55
import PageTitle from '@site/src/components/PageTitle';
@@ -8,47 +8,90 @@ import PageTitle from '@site/src/components/PageTitle';
88

99
<PageTitle title="Redis XINFO GROUPS Command (Documentation) | Dragonfly" />
1010

11+
## Introduction
12+
13+
In Dragonfly, as well as in Redis and Valkey, the `XINFO GROUPS` command provides information about consumer groups associated with a specific stream.
14+
This command is essential for monitoring and managing stream processing tasks, providing insights into consumer group configurations and activity.
15+
1116
## Syntax
1217

13-
XINFO GROUPS key
18+
```shell
19+
XINFO GROUPS key
20+
```
1421

15-
**ACL categories:** @read, @stream, @slow
22+
## Parameter Explanations
1623

17-
**XINFO GROUPS** command returns details of every consumer group
18-
that belong to the specified stream **<key\>**.
24+
- `key`: The key of the stream for which consumer groups information is requested.
1925

20-
The command returns the following details for each group:
26+
## Return Values
2127

22-
* **name:** The consumer group's name
23-
* **consumers:** The number of consumers in the group
24-
* **pending:** The length of the group's pending entries list (PEL),
25-
which are messages that were delivered but are yet to be acknowledged.
26-
* **last-delivered-id:** The ID of the last entry delivered to the
27-
group's consumers.
28+
The command returns a list of dictionaries, each dictionary representing a consumer group and its details.
29+
The details include fields such as `name`, `consumers`, `pending`, `last-delivered-id`, etc.
2830

29-
## Return
31+
## Code Examples
3032

31-
[Array reply](https://redis.io/docs/reference/protocol-spec/#arrays):
32-
a list of consumer groups.
33+
### Basic Example
3334

34-
## Example
35+
Get information about consumer groups for a stream:
3536

3637
```shell
38+
dragonfly> XGROUP CREATE mystream mygroup $
39+
OK
3740
dragonfly> XINFO GROUPS mystream
3841
1) 1) "name"
3942
2) "mygroup"
4043
3) "consumers"
41-
4) (integer) 2
44+
4) (integer) 0
4245
5) "pending"
43-
6) (integer) 10
46+
6) (integer) 0
4447
7) "last-delivered-id"
45-
8) "1623910467320-1"
48+
8) "0-0"
49+
```
50+
51+
### Monitor Multiple Consumer Groups
52+
53+
Creating and monitoring multiple consumer groups:
54+
55+
```shell
56+
dragonfly> XGROUP CREATE mystream group1 $
57+
OK
58+
dragonfly> XGROUP CREATE mystream group2 $
59+
OK
60+
dragonfly> XINFO GROUPS mystream
61+
1) 1) "name"
62+
2) "group1"
63+
3) "consumers"
64+
4) (integer) 0
65+
5) "pending"
66+
6) (integer) 0
67+
7) "last-delivered-id"
68+
8) "0-0"
4669
2) 1) "name"
47-
2) "another-group"
70+
2) "group2"
4871
3) "consumers"
49-
4) (integer) 1
72+
4) (integer) 0
5073
5) "pending"
51-
6) (integer) 1
74+
6) (integer) 0
5275
7) "last-delivered-id"
53-
8) "1623910847311-1"
76+
8) "0-0"
5477
```
78+
79+
## Best Practices
80+
81+
- Regularly use `XINFO GROUPS` to check on the health and status of consumer groups in your stream processing architecture.
82+
- Ensure consumer groups are correctly created with unique and descriptive names to avoid confusion and manage them effectively.
83+
84+
## Common Mistakes
85+
86+
- Omitting the `key` parameter, which is necessary to identify the stream for which group information is needed.
87+
- Assuming that `XINFO GROUPS` modifies consumer groups; it only retrieves information.
88+
89+
## FAQs
90+
91+
### What happens if the stream key does not exist?
92+
93+
If the stream key does not exist, `XINFO GROUPS` returns an empty list as there are no consumer groups associated with a nonexistent stream.
94+
95+
### Can `XINFO GROUPS` be used on keys that are not streams?
96+
97+
No, `XINFO GROUPS` is specific to streams, and attempting to use it on a non-stream key will result in an error.

0 commit comments

Comments
 (0)