Updated on 2025-12-29 GMT+08:00

Creating a Queue

Function

This API is used to create a queue.

Calling Method

For details, see Calling APIs.

URI

PUT /v2/rabbitmq/{project_id}/instances/{instance_id}/vhosts/{vhost}/queues

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID.

instance_id

Yes

String

Instance ID.

vhost

Yes

String

Virtual host name. If the name contains a slash (/), replace it with __F_SLASH__. Otherwise, the calling fails. For example, if the virtual host name is /test, the input parameter is __F_SLASH__test.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Queue name.

auto_delete

Yes

Boolean

Indicates whether to enable automatic deletion.

durable

No

Boolean

Indicates whether to enable data persistence (The AMQP version does not have this field because data persistence is enabled by default).

dead_letter_exchange

No

String

Name of the dead letter exchange. Rejected and expired messages are re-sent to this exchange.

dead_letter_routing_key

No

String

Routing key of the dead letter exchange. The dead letter exchange sends dead letter messages to the queue with a matching routing key.

message_ttl

No

Long

Indicates for how long a message in this queue can be retained.

lazy_mode

No

String

To make this queue lazy, enter lazy. Lazy queues store more messages on disk and save memory. If this parameter is not set, messages are stored in memory and delivered quickly. (AMQP stores messages to disks by default. This field is not involved.)

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

name

String

Queue name.

auto_delete

Boolean

Indicates whether to enable automatic deletion.

durable

Boolean

Indicates whether to enable data persistence (The AMQP version does not have this field because data persistence is enabled by default).

dead_letter_exchange

String

Name of the dead letter exchange. Rejected and expired messages are re-sent to this exchange.

dead_letter_routing_key

String

Routing key of the dead letter exchange. The dead letter exchange sends dead letter messages to the queue with a matching routing key.

message_ttl

Long

Indicates for how long a message in this queue can be retained.

lazy_mode

String

To make this queue lazy, enter lazy. Lazy queues store more messages on disk and save memory. If this parameter is not set, messages are stored in memory and delivered quickly. (AMQP stores messages to disks by default. This field is not involved.)

Example Requests

Creating a queue

PUT https://{endpoint}/v2/rabbitmq/{project_id}/instances/{instance_id}/vhosts/{vhost}/queues

{
  "name" : "string",
  "auto_delete" : true,
  "durable" : true,
  "dead_letter_exchange" : "string",
  "dead_letter_routing_key" : "string",
  "message_ttl" : 6000,
  "lazy_mode" : "string"
}

Example Responses

Status code: 200

Successful

{
  "name" : "string",
  "auto_delete" : true,
  "durable" : true,
  "dead_letter_exchange" : "string",
  "dead_letter_routing_key" : "string",
  "message_ttl" : 60000,
  "lazy_mode" : "string"
}

Status Codes

Status Code

Description

200

Successful

Error Codes

See Error Codes.