Creates a message queue.

Request

A request consists of the following parts:

  • Request line

    PUT /$queueName HTTP/1.1

  • Operation-specific request headers

    None. For more information about common request parameters, see Common parameters.

  • Request body

    The request body is in XML format. It contains the parameters of the queue. These parameters are optional.

Parameter Description Value
DelaySeconds The interval between the time when a message arrives at the queue and the time when the message becomes consumable. Unit: seconds. Valid values: integers from 0 to 604800 (7 days). Default value: 0.
MaximumMessageSize The maximum size of a message body. Unit: bytes. Valid values: integers from 1024 (1 KB) to 65536 (64 KB). Default value: 65536 (64 KB).
MessageRetentionPeriod The maximum retention period of a message in the queue. After the period that is specified by this parameter expires, the message is deleted from the queue, regardless of whether the message has been consumed. Unit: seconds. Valid values: integers from 60 (1 minute) to 604800 (7 days). Default value: 259200 (3 days).
VisibilityTimeout The length of time for which a message remains inactive after it is consumed from the queue. Unit: seconds. Valid values: integers from 1 to 43200 (12 hours). Default value: 30.
PollingWaitSeconds The maximum length of time for which a ReceiveMessage request waits for a message to arrive if no messages exist in the queue. Unit: seconds. Valid values: integers from 0 to 30. Default value: 0.
Note

If you set the PollingWaitSeconds parameter to a value greater than zero and no messages exist in the queue, all ReceiveMessage requests wait for a message to arrive. If no message arrives at the queue before the time that is specified by the parameter expires, the MessageNotExist error is returned. If a message arrives at the queue before the time expires, the ReceiveMessage request is processed and a success response is returned.

Response

A response consists of a status line, HTTP headers, and a response body.

  • HTTP status code

    HTTP/1.1 201 Created

    The message queue names must be unique under an Alibaba Cloud account. If the parameter values (including the queue name) that you specify for a queue are the same as those of an existing queue, a 204 No Content response is returned. If the queue name is the same and other parameter values are different, a 409 Conflict response is returned.

  • Operation-specific response headers
    Parameter Description
    Location The URL of the created queue. The format is: http://$AccountId.mqs-<Region>.aliyuncs.com/$queueName.
  • Response body

    None.

Error codes

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
  • Sample requests
        PUT  /$queueName HTTP/1.1
        Host: $AccountId.mqs-cn-hangzhou.aliyuncs.com
        Date: Wed, 08 Mar 2012 12:00:00 GMT
        x-mqs-version: 2014-07-08
        Authorization:MQS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE=
    
        <? xml version=”1.0” encoding=”UTF-8”? >
        <Queue xmlns=”http://mqs.aliyuncs.com/doc/v1/”>
        <VisibilityTimeout>60</VisibilityTimeout>
        <MaximumMessageSize>65536</MaximumMessageSize>
        <MessageRetentionPeriod>1209600</MessageRetentionPeriod>
        </Queue>            
  • Sample responses
        HTTP/1.1 201 Created
        x-mqs-request-id: 512B2A634403E52B1956133E
        x-mqs-version: 2015-06-06
        Location: http://$AccountId.mqs-cn-hangzhou.aliyuncs.com/$queueName