XGROUP

Since 1.1.0Streams

Syntax

XGROUP
  • Flags: write
  • ACL categories: @slow, @stream, @write
  • Arity: -2

XGROUP is a container: its subcommands create and manage consumer groups. A consumer group is a named reader of a stream that shares the stream's entries among its consumers, each entry going to one of them, and tracks which entries each consumer has been given and not yet acknowledged. It is how a stream is used as a work queue.

Subcommand
XGROUP CREATEcreate a group, reading from the start, the end, or an ID
XGROUP CREATECONSUMERadd a consumer before it first reads
XGROUP DELCONSUMERremove a consumer and its pending entries
XGROUP SETIDmove where the group reads from
XGROUP DESTROYdelete a group
XGROUP HELPlist the subcommands (since 1.2.1)

Consumers read with XREADGROUP, acknowledge with XACK, and take over another's stalled entries with XCLAIM or XAUTOCLAIM. XPENDING and XINFO GROUPS show what is outstanding.

XGROUP alone, or with a name that is not a subcommand, is an error. Since 1.2.1 the error for an unknown subcommand is Redis's, which names it and suggests XGROUP HELP; before, it was ERR unknown subcommand for XGROUP.

A subcommand on a key that does not exist gets Redis's error, ERR The XGROUP subcommand requires the key to exist. Note that for CREATE you may want to use the MKSTREAM option to create an empty stream automatically.; in 1.2.0, XGROUP DESTROY answered 0. XGROUP CREATE takes MKSTREAM and ENTRIESREAD only after the ID, so a key or group called mkstream no longer creates the stream.

Examples

> XGROUP
(error) ERR wrong number of arguments for 'xgroup' command
> XGROUP NOPE
(error) ERR unknown subcommand 'NOPE'. Try XGROUP HELP.
> XGROUP CREATE jobs workers 0
OK

Subcommands

  • XGROUP CREATE: Creates the consumer group group on the stream at key, which will deliver entries after id: 0 for every entry, $ for only those added from now on.
  • XGROUP CREATECONSUMER: Creates the consumer consumer in the consumer group group of the stream at key.
  • XGROUP DELCONSUMER: Deletes the consumer consumer from the consumer group group, with its pending entries.
  • XGROUP DESTROY: Deletes the consumer group group of the stream at key, with its consumers and its pending entries list.
  • XGROUP HELP: Lists the XGROUP subcommands, with a line or two on what each does, as Redis does.
  • XGROUP SETID: Sets the last delivered ID of the consumer group group: the ID after which XREADGROUP with > delivers entries.