Upstash Documentation

XCLAIM

Claim pending messages.
3 min read

Use XCLAIM to change the owner of specific pending entries in a consumer group.

The entries must have been idle for at least <min-idle-time> milliseconds, which is what keeps two recovery attempts from stealing the same work from each other: the first claim resets the idle time and the second one then finds nothing to take. Claiming resets the entry's delivery time and increments its delivery counter, unless JUSTID is used, which returns only the IDs and leaves the counter alone.

IDLE and TIME set the new idle time or the last delivery time explicitly, RETRYCOUNT overrides the delivery counter, and FORCE creates a pending entry for IDs that exist in the stream but are not currently pending. Entries that no longer exist in the stream are removed from the pending list instead of being claimed.

When you want to claim whatever is idle rather than specific IDs, use XAUTOCLAIM.

Syntax#

Arguments#

ArgumentRequiredRepeatableDescription
<key>YesNoRedis key targeted by the command.
<group>YesNoConsumer group name.
<consumer>YesNoConsumer name within the group.
<min-idle-time>YesNoOnly claim entries that have been idle at least this many milliseconds.
<ID>YesYesStream entry ID.
IDLE <ms>NoNoSet the entry's idle time to this many milliseconds.
TIME <unix-time-milliseconds>NoNoSet the entry's last-delivery time to this Unix timestamp in milliseconds.
RETRYCOUNT <count>NoNoSet the entry's delivery counter to this value.
FORCENoNoCreate the pending entry even when the ID is not in the group's pending list.
JUSTIDNoNoReturn only entry IDs, without their fields and values.
LASTID <lastid>NoNoNew last-delivered ID for the group.

Response#

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.

ProtocolReply
RESP2Array of entry arrays, or array of IDs with JUSTID
RESP3Array of entry arrays, or array of IDs with JUSTID
Note

Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples#

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Redis CLI
@upstash/redis
upstash_redis
ioredis
node-redis
redis-py
go-redis
jedis
redis-rs