Amazon Simple Queue Service
API Reference (API Version 2011-10-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

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.

[Note]Note

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

If you provide the name of an existing queue, along with the exact names and values of all the queue's attributes, CreateQueue returns the queue URL for the existing queue. If the queue name, attribute names, or attribute values do not match an existing queue, CreateQueue returns an error.

[Tip]Tip

Use GetQueueUrl to get a queue's URL. GetQueueUrl requires only the QueueName parameter.

The default value for the queue's attributes are set when the queue is created. You can override these values with the Attribute.n.name and Attribute.n.value request parameters. For the default values of each attribute, see the table of parameters in Request Parameters.

[Note]Note

Some API operations take lists of parameters. These lists are specified using the param.n notation. Values of n are integers starting from 1. For example, a parameter list with two elements looks like this:

&Attribute.1=this
&Attribute.2=that

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 Common Query Parameters).

NameDescriptionRequired

QueueName

The name to use for the queue created.

Type: String

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

Yes

Attribute.n.Name

The name of the attribute you want to set.

  • VisibilityTimeout—The length of time (in seconds) that a message received from a queue will be invisible to other receiving components when they ask to receive messages. For more information about VisibilityTimeout, see Visibility Timeout in the Amazon SQS Developer Guide.

  • Policy—The formal description of the permissions for a resource. For more information about Policy, see Basic Policy Structure in the Amazon SQS Developer Guide.

  • MaximumMessageSize—The limit of how many bytes a message can contain before Amazon SQS rejects it.

  • MessageRetentionPeriod—The number of seconds Amazon SQS retains a message.

  • DelaySeconds—The time in seconds that the delivery of all messages in the queue will be delayed.

No

Attribute.n.Value

The value of the attribute you want to set.

Constraints: Constraints are specific for each value.

  • VisibilityTimeout—An integer from 0 to 43200 (12 hours). The default for this attribute is 30.

  • Policy—A valid form-url-encoded policy. For more information about policy structure, see Basic Policy Structure in the Amazon SQS Developer Guide. For more information about form-url-encoding, see http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1.

  • MaximumMessageSize—An integer from 1024 bytes (1 KiB) up to 65536 bytes (64 KiB). The default for this attribute is 65536 (64 KiB).

  • MessageRetentionPeriod—Integer representing seconds, from 60 (1 minute) to 1209600 (14 days). The default for this attribute is 345600 (4 days).

  • DelaySeconds—An integer from 0 to 900 (15 minutes). The default for this attribute is 0 (zero).

Default: Varies according to attribute

Yes, if there is a corresponding Name Attribute.n.name parameter

Response Elements

The following table lists the elements that the CreateQueue response includes in addition to the elements that are 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 that you created.

Type: String

Ancestor: CreateQueueResult

Special Errors

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

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 an attribute name or value that differs from the name or value for the existing attribute.

400

Examples

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

Sample Request

http://sqs.us-east-1.amazonaws.com/
?Action=CreateQueue
&QueueName=testQueue
&Attribute.1.Name=VisibilityTimeout
&Attribute.1.Value=40
&Version=2011-10-01
&SignatureMethod=HmacSHA256
&Expires=2011-10-18T22%3A52%3A43PST
&AWSAccessKeyId=0GS7553JW74RRM612K02EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

Sample Response

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