CreateQueue

Description

The CreateQueue action creates a new queue.

When you request CreateQueue, you provide a name for the queue. To successfully create a new queue, you must provide a name that is unique within the scope of your own queues. If you provide the name of an existing queue, a new queue isn't created and an error isn't returned. Instead, the request succeeds and the queue URL for the existing queue is returned (for more information about queue URLs, see Queue and Message Identifiers in the Amazon SQS Developer Guide). Exception: if you provide a value for DefaultVisibilityTimeout that is different from the value for the existing queue, you receive an error.

[Note]Note

If you delete a queue, you must wait at least 60 seconds before creating a queue with the same name.

A default value for the queue's visibility timeout (30 seconds) is set when the queue is created. You can override this value with the DefaultVisibilityTimeout request parameter. For more information, see Visibility Timeout in the Amazon SQS Developer Guide.

Request Parameters

The following table lists the special request parameters the CreateQueue action uses in addition to the common parameters all actions use (for more information, see Request Parameters Common to All Actions).

NameDescriptionRequired

QueueName

The name to use for the queue created.

Type: String

Constraints: Maximum 80 characters; alphanumeric characters, hyphens (-), and underscores (_) are allowed.

Yes

DefaultVisibilityTimeout

The visibility timeout (in seconds) to use for this queue.

Type: Integer

Constraints: 0 to 43200 (maximum 12 hours)

Default: 30 seconds

No

Response Elements

The following table lists the elements the CreateQueue response includes in addition to the elements returned in all successful responses (for more information, see Responses section in the Amazon SQS Developer Guide.

NameDescription

QueueUrl

The queue URL for the queue you created.

Type: String

Ancestor: CreateQueueResult

Special Errors

The following table lists the special errors the CreateQueue action returns in addition to the common errors all actions return (for more information, see Errors Common to all Actions).

ErrorDescriptionHTTP Status Code

AWS.SimpleQueueService.QueueDeletedRecently

You must wait 60 seconds after deleting a queue before you can create another with the same name.

400

AWS.SimpleQueueService.QueueNameExists

Queue already exists. SQS returns this error only if the request includes a DefaultVisibilityTimeout value that differs from the value for the existing queue.

400

Examples

The following example Query request creates a new queue named queue2.

Sample Request

http://queue.amazonaws.com/
?Action=CreateQueue
&DefaultVisibilityTimeout=40
&QueueName=testQueue
&Version=2009-02-01
&SignatureMethod=HmacSHA256
&Expires=2009-04-18T22%3A52%3A43PST
&AWSAccessKeyId=0GS7553JW74RRM612K02EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

Sample Response

<CreateQueueResponse>
    <CreateQueueResult>
        <QueueUrl>
            http://queue.amazonaws.com/123456789012/testQueue
        </QueueUrl>
    </CreateQueueResult>
    <ResponseMetadata>
        <RequestId>
            7a62c49f-347e-4fc4-9331-6e8e7a96aa73
        </RequestId>
    </ResponseMetadata>
</CreateQueueResponse>

Related Actions