Skip to content

Docs Originality Update - Batch #9 #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 10, 2025
Merged
96 changes: 86 additions & 10 deletions docs/command-reference/stream/xack.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Learn how to use Redis XACK to acknowledge the processing of a message from a stream by a consumer.
description: Learn how to use Redis XACK to acknowledge the processing of a message from a stream by a consumer.
---

import PageTitle from '@site/src/components/PageTitle';
Expand All @@ -8,26 +8,102 @@ import PageTitle from '@site/src/components/PageTitle';

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

## Introduction

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.
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.
After successfully processing a message, a consumer should call `XACK` to prevent reprocessing and remove the message from the Pending Entries List (PEL).

## Syntax

XACK key group id [id ... ]
```shell
XACK key group id [id ...]
```

**Time complexity:** O(1) for each message ID processed.
- **Time complexity:** O(1) for each message ID processed.
- **ACL categories:** @write, @stream, @fast

**ACL categories:** @write, @stream, @fast
## Parameter Explanations

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

## Return Values

## Return
- The command returns an integer indicating the number of messages that were successfully acknowledged.
- Message IDs that are not part of the PEL (i.e., already been acknowledged) will not be considered successful acknowledgments.
- If the stream or the consumer group does not exist, the command simply returns `0`.

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

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.
### Basic Acknowledgement Example

## Examples
Acknowledge a single message that has been processed:

```shell
dragonfly> XACK mystream mygroup 1526569495631-0
dragonfly$> XADD mystream * name Alice age 20
"1609097574170-0"

dragonfly$> XGROUP CREATE mystream mygroup 0 MKSTREAM
OK

dragonfly$> XREADGROUP GROUP mygroup consumer-1 COUNT 1 STREAMS mystream >
1) 1) "mystream"
2) 1) 1) "1609097574170-0"
2) 1) "name"
2) "Alice"
3) "age"
4) "20"

dragonfly$> XACK mystream mygroup "1609097574170-0"
(integer) 1
```

### Acknowledging Multiple Messages

Acknowledge multiple messages after processing:

```shell
dragonfly$> XADD mystream * name Bob age 25
"1609097574171-0"

dragonfly$> XADD mystream * name Charlie age 30
"1609097574172-0"

# The consumer reads the 2 new messages.
dragonfly$> XREADGROUP GROUP mygroup consumer-1 COUNT 2 STREAMS mystream >
# ...

# Acknowledge the 2 messages for the consumer group.
dragonfly$> XACK mystream mygroup "1609097574171-0" "1609097574172-0"
(integer) 2
```

### Handling Non-existent IDs

Acknowledge attempt on a non-existent message ID:

```shell
dragonfly$> XACK mystream mygroup "1609097574173-0"
(integer) 0 # No acknowledgment since the ID does not exist.
```

## Best Practices

- Use `XACK` to signal message processing completion to avoid reprocessing and free up resources.
- Implement proper error handling to manage message IDs that may no longer exist or are not yet acknowledged.

## Common Mistakes

- Attempting to acknowledge messages using IDs that were never read by the group.

## FAQs

### What happens if the message ID is not found?

If the message ID does not exist in the pending entries list of the consumer group, `XACK` returns `0`.

### Can `XACK` be used for automatic acknowledgement?

No, `XACK` requires explicit calls to acknowledge messages after successful processing by consumers.
3 changes: 3 additions & 0 deletions docs/command-reference/stream/xadd.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Streams are data structures that enable storing and processing ordered logs of e
XADD key [<MAXLEN | MINID> [~ | =] threshold] <* | id> field value [field value ...]
```

- **Time complexity:** O(1) when adding a new entry, O(N) when trimming where N being the number of entries evicted.
- **ACL categories:** @write, @stream, @fast

## Parameter Explanations

- `key`: The key of the stream where the entry will be appended.
Expand Down
3 changes: 3 additions & 0 deletions docs/command-reference/stream/xautoclaim.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ which is particularly useful in scenarios where message processing needs to be r
XAUTOCLAIM key group consumer min-idle-time start [COUNT count] [JUSTID]
```

- **Time complexity:** O(1) if `COUNT` is small.
- **ACL categories:** @write, @stream, @fast

## Parameter Explanations

- `key`: The key of the stream.
Expand Down
3 changes: 3 additions & 0 deletions docs/command-reference/stream/xclaim.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ XCLAIM key group consumer min-idle-time id [id ...] [IDLE ms] [TIME ms-unix-time
[RETRYCOUNT count] [FORCE] [JUSTID]
```

- **Time complexity:** O(log N) with N being the number of messages in the pending entries list (PEL) of the consumer group.
- **ACL categories:** @write, @stream, @fast

## Parameter Explanations

- `key`: The key of the stream.
Expand Down
3 changes: 3 additions & 0 deletions docs/command-reference/stream/xdel.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ This command is particularly useful for managing data in stream-like structures
XDEL key ID [ID ...]
```

- **Time complexity:** O(1) for each single item to delete in the stream, regardless of the stream size.
- **ACL categories:** @write, @stream, @fast

## Parameter Explanations

- `key`: The key of the stream from which entries are to be deleted.
Expand Down
3 changes: 3 additions & 0 deletions docs/command-reference/stream/xgroup-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ This command is essential for managing distributed message processing systems wh
XGROUP CREATE key group <id | $> [MKSTREAM]
```

- **Time complexity:** O(1)
- **ACL categories:** @write, @stream, @slow

## Parameter Explanations

- `key`: The key name of the stream.
Expand Down
3 changes: 3 additions & 0 deletions docs/command-reference/stream/xgroup-createconsumer.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ This command is part of the streams data type which facilitates managing consume
XGROUP CREATECONSUMER key group consumer
```

- **Time complexity:** O(1)
- **ACL categories:** @write, @stream, @slow

## Parameter Explanations

- `key`: The key of the stream for which the consumer is being created.
Expand Down
3 changes: 3 additions & 0 deletions docs/command-reference/stream/xgroup-delconsumer.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Therefore, be sure to claim or acknowledge any pending messages before removing
XGROUP DELCONSUMER key group consumer
```

- **Time complexity:** O(1)
- **ACL categories:** @write, @stream, @slow

## Parameter Explanations

- `key`: The key of the stream.
Expand Down
3 changes: 3 additions & 0 deletions docs/command-reference/stream/xgroup-destroy.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Use this command only when absolutely necessary.**
XGROUP DESTROY key group
```

- **Time complexity:** O(N) where N is the number of entries in the group's pending entries list (PEL).
- **ACL categories:** @write, @stream, @slow

## Parameter Explanations

- `key`: The name of the stream from which the consumer group will be deleted.
Expand Down
3 changes: 3 additions & 0 deletions docs/command-reference/stream/xgroup-setid.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ This command is beneficial when you need to reprocess messages or adjust a consu
XGROUP SETID key group <id | $>
```

- **Time complexity:** O(1)
- **ACL categories:** @write, @stream, @slow

## Parameter Explanations

- `key`: The key of the stream.
Expand Down
3 changes: 3 additions & 0 deletions docs/command-reference/stream/xinfo-consumers.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ This command is helpful for monitoring the activity of consumers connected to a
XINFO CONSUMERS key group
```

- **Time complexity:** O(1)
- **ACL categories:** @read, @stream, @slow

## Parameter Explanations

- `key`: The key of the stream.
Expand Down
132 changes: 99 additions & 33 deletions docs/command-reference/stream/xinfo-groups.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Learn how to use Redis XINFO GROUPS to get information about consumer groups of a stream.
description: Learn how to use Redis XINFO GROUPS to get information about consumer groups of a stream.
---

import PageTitle from '@site/src/components/PageTitle';
Expand All @@ -8,47 +8,113 @@ import PageTitle from '@site/src/components/PageTitle';

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

## Introduction

In Dragonfly, as well as in Redis and Valkey, the `XINFO GROUPS` command provides information about consumer groups associated with a specific stream.
This command is essential for monitoring and managing stream processing tasks, providing insights into consumer group configurations and activity.

## Syntax

XINFO GROUPS key
```shell
XINFO GROUPS key
```

- **Time complexity:** O(1)
- **ACL categories:** @read, @stream, @slow

## Parameter Explanations

**ACL categories:** @read, @stream, @slow
- `key`: The key of the stream for which consumer groups information is requested.

**XINFO GROUPS** command returns details of every consumer group
that belong to the specified stream **<key\>**.
## Return Values

The command returns the following details for each group:
- The command returns a list of dictionaries, each dictionary representing a consumer group and its details.
- The details include fields such as `name`, `consumers`, `pending`, `last-delivered-id`, etc.
- `name`: the consumer group's name.
- `consumers`: the number of consumers within the group.
- `pending`: the length of the group's pending entries list (PEL), which are messages that were delivered but not yet acknowledged.
- `last-delivered-id`: the ID of the last entry delivered to the group's consumer(s).
- `entries-read`: number of entries read by the group's consumers.
- `lag`: the number of entries that are yet to be delivered to the group's consumers.

* **name:** The consumer group's name
* **consumers:** The number of consumers in the group
* **pending:** The length of the group's pending entries list (PEL),
which are messages that were delivered but are yet to be acknowledged.
* **last-delivered-id:** The ID of the last entry delivered to the
group's consumers.
## Code Examples

## Return
### Basic Example

Get information about consumer groups for a stream:

```shell
dragonfly$> XGROUP CREATE mystream mygroup $ MKSTREAM
OK

dragonfly$> XINFO GROUPS mystream
1) 1) "name"
2) "mygroup"
3) "consumers"
4) (integer) 0
5) "pending"
6) (integer) 0
7) "last-delivered-id"
8) "0-0"
9) "entries-read"
10) (nil)
11) "lag"
12) (integer) 0
```

[Array reply](https://redis.io/docs/reference/protocol-spec/#arrays):
a list of consumer groups.
### Monitor Multiple Consumer Groups

## Example
Creating and monitoring multiple consumer groups:

```shell
dragonfly> XINFO GROUPS mystream
1) 1) "name"
2) "mygroup"
3) "consumers"
4) (integer) 2
5) "pending"
6) (integer) 10
7) "last-delivered-id"
8) "1623910467320-1"
2) 1) "name"
2) "another-group"
3) "consumers"
4) (integer) 1
5) "pending"
6) (integer) 1
7) "last-delivered-id"
8) "1623910847311-1"
dragonfly$> XGROUP CREATE mystream group1 $ MKSTREAM
OK

dragonfly$> XGROUP CREATE mystream group2 $
OK

dragonfly$> XINFO GROUPS mystream
1) 1) "name"
2) "group1"
3) "consumers"
4) (integer) 0
5) "pending"
6) (integer) 0
7) "last-delivered-id"
8) "0-0"
9) "entries-read"
10) (nil)
11) "lag"
12) (integer) 0
2) 1) "name"
2) "group2"
3) "consumers"
4) (integer) 0
5) "pending"
6) (integer) 0
7) "last-delivered-id"
8) "0-0"
9) "entries-read"
10) (nil)
11) "lag"
12) (integer) 0
```

## Best Practices

- Regularly use `XINFO GROUPS` to check on the health and status of consumer groups in your stream processing system.
- Ensure consumer groups are correctly created with unique and descriptive names to avoid confusion and ease monitoring and management.

## Common Mistakes

- Assuming that `XINFO GROUPS` modifies consumer groups; it only retrieves information.

## FAQs

### What happens if the stream key does not exist?

If the stream key does not exist, `XINFO GROUPS` returns an error.

### Can `XINFO GROUPS` be used on keys that are not streams?

No, `XINFO GROUPS` is specific to streams, and attempting to use it on a non-stream key will result in an error.
Loading