• Distributed Message Service

dms
  1. Help Center
  2. Distributed Message Service
  3. API Reference
  4. APIs for Managing Queues and Messages
  5. Creating a Consumer Group

Creating a Consumer Group

Function

This API is used to create a consumer group.

Multiple consumer groups can be created for a queue at a time.

NOTE:

After you create a consumer group, it takes 1s to 3s to initialize the system. If you operate the queue immediately after creating the consumer group, the consumption may fail. You are advised to perform operations 3s later.

URI

URI format: POST /v1.0/{project_id}/queues/{queue_id}/groups

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Type

Mandatory or Not

Description

project_id

String

Yes

Indicates the ID of a project.

queue_id

String

Yes

Indicates the ID of a queue.

Request

Request parameters

Table 2 describes the parameters of this API.

Table 2 Parameter description

Parameter

Type

Mandatory or Not

Description

groups

Array

Yes

Indicates the consumer group information.

Table 3 groups parameter description

Parameter

Type

Mandatory or Not

Description

name

String

Yes

Indicates the name of a consumer group.

The value is a string of 1 to 32 characters that contain letters, digits, hyphens (-), and underscores (_).

Example request

{
  "groups" : [{
      "name" : "group-aa"
    }
  ]
}

Response

Response parameters

Table 4 describes the response parameters.

Table 4 Parameter description

Parameter

Type

Description

id

String

Indicates the consumer group ID.

name

String

Indicates the name of a consumer group.

Example response

{
  "groups" : [{
      "id" : "g-02fb1974-9be1-4eee-8448-ed2d3e89884a",
      "name" : "group-aa"
    }
  ]
}

Status Code

Table 5 lists the status code indicating that the operation is successful. For details about the status codes indicating that the operation fails, see Status Code.

Table 5 Status code

Status Code

Description

201

The consumer group is created successfully.