xautoclaim
XAUTOCLAIM
Apply for Redis Developer Course
|
Redis Regular Inspection / Technical Support
|
Redis Enterprise Server
|
|---|
Transfer ownership of pending stream entries
Transfers ownership of pending stream entries that match the given criteria.
It is like calling XPENDING and XCLAIM.
Internally it uses a SCAN-style walk, a simpler way to recover from failed deliveries.
Available since version 6.2.
Like XCLAIM, it works on stream <key> in consumer group <group>.
It transfers to <consumer> messages pending for at least <min-idle-time> milliseconds whose ID is at least <start>.
Example
| Command> | XADD sensor1 * temp 10 |
| Command> | XADD sensor1 * temp 20 |
| Command> | XGROUP CREATE sensor1 CG 0 |
| Command> | XREADGROUP GROUP CG C1 count 1 STREAMS sensor1 > |
| Result> |
1) 1) "sensor1" 2) 1) 1) "1624776138517-0" 2) 1) "temp" 2) "10" |
| Command> | XREADGROUP GROUP CG C1 count 1 STREAMS sensor1 > |
| Result> |
1) 1) "sensor1" 2) 1) 1) "1624776140772-0" 2) 1) "temp" 2) "20" |
| Command> | XAUTOCLAIM sensor1 CG C2 5000 0-0 Moves the 2 pending entries from C1 to C2. |
| Result> |
1) "0-0" 2) 1) 1) "1624776138517-0" 2) 1) "temp" 2) "10" 2) 1) "1624776140772-0" 2) 1) "temp" 2) "20" |
| Command> | XPENDING sensor1 CG |
| Result> |
1) (integer) 2 2) "1624776138517-0" 3) "1624776140772-0" 4) 1) 1) "C2" Now owned by C2. 2) "2" |
- <count> (default 100) is an upper limit on how many items to try to claim. Internally the command scans the consumer group's Pending Entry List (PEL) from <start> and picks entries whose idle time is at least <min-idle-time>. The maximum number of pending entries scanned is <count> times 10 (hard-coded). So fewer entries than requested may be claimed.
- JUSTID changes the reply to an array of successfully claimed IDs only, without the message bodies. With this option the retry counter is not incremented.
- The command returns claimed stream IDs and entries as arrays. If no PEL entries remain, it returns the special ID 0-0 to signal completion. You can still call XAUTOCLAIM after a 0-0 scan. If enough time has passed, previously pending entries may become claimable.
- Only messages idle longer than <min-idle-time> are claimed, and idle time is reset. That way only one consumer can successfully claim a given pending message at a time, which reduces (but does not eliminate) double processing.
- Claiming with XAUTOCLAIM also increments the delivery attempt count. Messages that cannot be processed (for example because the consumer always crashes) show a high delivery count that monitoring can detect.
Syntax
XAUTOCLAIM key group consumer min-idle-time start [COUNT count] [JUSTID]
- Available since version 6.2.0.
- Time complexity is O(1) if COUNT is small.
| << XCLAIM | XAUTOCLAIM | XINFO >> |
|---|
Email
답글이 올라오면 이메일로 알려드리겠습니다.
