XGROUP [CREATE key groupname id-or-$] [SETID key groupname id-or-$] [DESTROY key groupname] [DELCONSUMER key groupname consumername]

    Time complexity: O(1) for all the subcommands, with the exception of the DESTROY subcommand which takes an additional O(M) time in order to delete the M entries inside the consumer group pending entries list (PEL).

    This command is used in order to manage the consumer groups associated with a stream data structure. Using you can:

    • Create a new consumer group associated with a stream.
    • Remove a specific consumer from a consumer group.

    To create a new consumer group, use the following form:

    If instead you want consumers to fetch the whole stream history, use zero as the starting ID for the consumer group:

    Of course it is also possible to use any other valid ID. If the specified consumer group already exists, the command returns a -BUSYGROUP error. Otherwise the operation is performed and OK is returned. There are no hard limits to the number of consumer groups you can associate to a given stream.

    If the specified stream doesn't exist when creating a group, an error will be returned. You can use the optional subcommand as the last argument after the ID to automatically create the stream, if it doesn't exist. Note that if the stream is created in this way it will have a length of 0:

      The consumer group will be destroyed even if there are active consumers and pending messages, so make sure to call this command only when really needed.

      To just remove a given consumer from a consumer group, the following form is used:

      Consumers in a consumer group are auto-created every time a new consumer name is mentioned by some command. However sometimes it may be useful to remove old consumers since they are no longer used. This form returns the number of pending messages that the consumer had before it was deleted.

      1. XGROUP SETID mystream consumer-group-name 0

      Finally to get some help if you don't remember the syntax, use the HELP subcommand: