Creates a queue.

Name Value
API CreateQueue
Action mns:CreateQueue
Resource acs:mns:$region:$accountid:/queues/$queueName

Description

The name of a queue is a string that can be a maximum of 255 characters in length and can contain letters, digits, and hyphens (-). It must start with a letter or digit.

You can create a maximum of 1,000 queues within an Alibaba Cloud account. If you want to create more queues, submit a ticket.

Request

Each request consists of the following parts:

  • Request line

    PUT /queues/$queueName HTTP/1.1

  • Operation-specific request headers

    None.

  • Request Body
    The request body is in the XML format. It contains the following parameters that are used to create a queue. These parameters are optional.
    Parameter Description Value
    DelaySeconds The delay period after which a message sent to the queue can be consumed. Unit: seconds. Valid values: 0 to 604800 seconds. Data type: integer. Default value: 0.
    MaximumMessageSize The maximum size of a message body that can be sent to the queue. Unit: bytes. Valid values: 1024 B to 65536 B. Data type: integer. Default value: 65536 B.
    MessageRetentionPeriod The maximum period for which a message can be retained in the queue. After the specified period, the message is deleted no matter whether the message is consumed. Unit: seconds. Valid values: 60 seconds to 604800 seconds. Data type: integer. Default value: 345600 seconds.
    VisibilityTimeout The invisibility period for which the received message remains the Inactive state. Unit: seconds. Valid values: 1 second to 43200 seconds. Data type: integer. Default value: 30.
    PollingWaitSeconds The maximum period for which a ReceiveMessage request waits if no message is available in the queue. Unit: seconds. Valid values: 0 to 30. Default value: 0.
    LoggingEnabled Indicates whether the log management feature is enabled for the queue. Valid values:
    • True: The log management feature is enabled.
    • False: The log management feature is disabled.
    Default value: False.
    Note
    • If you specify the PollingWaitSeconds parameter for a queue and no message is available in the queue, MNS holds each (Batch)ReceiveMessage request for long polling. Unit: seconds. If no message is sent to the queue within the period that is specified by the PollingWaitSeconds parameter, the MessageNotExist error message is returned. If a message is sent to the queue during the specified period, the message is returned to the consumer client.
    • We recommend that you reduce the number of concurrent long polling requests. MNS dynamically determines the maximum number of concurrent long polling requests based on the number of requests, waiting period of requests, and the number of IP addresses. If the number of long polling requests exceeds the upper limit, MNS does not hold the request and returns the 404MessageNotExist error. You are charged based on the number of requests. To avoid unnecessary costs, submit a ticket to increase the quota.

Response

Each response consists of the following parts:

  • HTTP Status Code

    HTTP/1.1 201 Created

    The name of each queue must be unique within an Alibaba Cloud account. If you create a queue whose name already exists, errors may occur. For example, if the parameters of the two queues are the same, the error code 204 (No Content) is returned. If the parameters of the two queues are different, the error code 409 (Conflict) is returned.

  • Operation-specific response headers
    Parameter Description
    Location The URL of the queue that was created. Syntax: http://$AccountId.mns. <Region>.aliyuncs.com/queues/$queueName.
  • Response Body

    None.

Examples

Sample requests

PUT  /queues/$queueName HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 08 Mar 2012 12:00:00 GMT
x-mns-version: 2015-06-06
Authorization:MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAM****

<? xml version="1.0" encoding="UTF-8"? >
<Queue xmlns="http://mns.aliyuncs.com/doc/v1/">
    <VisibilityTimeout>60</VisibilityTimeout>
    <MaximumMessageSize>65536</MaximumMessageSize>
    <MessageRetentionPeriod>1209600</MessageRetentionPeriod>
    <LoggingEnabled>True</LoggingEnabled>
</Queue>            

Sample success responses

HTTP/1.1 201 Created
x-mns-request-id:512B2A634403E52B1956****
x-mns-version: 2015-06-06
Location: http://$AccountId.mns.cn-hangzhou.aliyuncs.com/queues/$queueName         

Special error

Error code Error message HTTP status code
QueueAlreadyExist The queue you want to create is already exist. 409
InvalidArgument The value of Element should between Low and High seconds/bytes. 400
QueueNumExceededLimit The number of the queues you created has excceeded the limit. 400