CreateQueue - Amazon Simple Queue Service (original) (raw)

Creates a new standard or FIFO queue. You can pass one or more attributes in the request. Keep the following in mind:

Note

You can't change the queue type after you create it and you can't convert an existing standard queue into a FIFO queue. You must either create a new FIFO queue for your application or delete your existing standard queue and recreate it as a FIFO queue. For more information, see Moving From a Standard Queue to a FIFO Queue in the_Amazon SQS Developer Guide_.

To successfully create a new queue, you must provide a queue name that adheres to thelimits related to queues and is unique within the scope of your queues.

Note

After you create a queue, you must wait at least one second after the queue is created to be able to use the queue.

To retrieve the URL of a queue, use the GetQueueUrl action. This action only requires the QueueName parameter.

When creating queues, keep the following points in mind:

Request Syntax

{
   "Attributes": { 
      "string" : "string" 
   },
   "QueueName": "string",
   "tags": { 
      "string" : "string" 
   }
}

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

Attributes

A map of attributes with their corresponding values.

The following lists the names, descriptions, and values of the special request parameters that the CreateQueue action uses:

The following attributes apply only to dead-letter queues:

Note

The dead-letter queue of a FIFO queue must also be a FIFO queue. Similarly, the dead-letter queue of a standard queue must also be a standard queue.

The following attributes apply only to server-side-encryption:

The following attributes apply only to FIFO (first-in-first-out) queues:

The following attributes apply only to high throughput for FIFO queues:

To enable high throughput for FIFO queues, do the following:

If you set these attributes to anything other than the values shown for enabling high throughput, normal throughput is in effect and deduplication occurs as specified.

For information on throughput quotas, see Quotas related to messages in the Amazon SQS Developer Guide.

Type: String to string map

Valid Keys: All | Policy | VisibilityTimeout | MaximumMessageSize | MessageRetentionPeriod | ApproximateNumberOfMessages | ApproximateNumberOfMessagesNotVisible | CreatedTimestamp | LastModifiedTimestamp | QueueArn | ApproximateNumberOfMessagesDelayed | DelaySeconds | ReceiveMessageWaitTimeSeconds | RedrivePolicy | FifoQueue | ContentBasedDeduplication | KmsMasterKeyId | KmsDataKeyReusePeriodSeconds | DeduplicationScope | FifoThroughputLimit | RedriveAllowPolicy | SqsManagedSseEnabled

Required: No

QueueName

The name of the new queue. The following limits apply to this name:

Queue URLs and names are case-sensitive.

Type: String

Required: Yes

tags

Add cost allocation tags to the specified Amazon SQS queue. For an overview, see Tagging Your Amazon SQS Queues in the Amazon SQS Developer Guide.

When you use queue tags, keep the following guidelines in mind:

For a full list of tag restrictions, see Quotas related to queuesin the Amazon SQS Developer Guide.

Type: String to string map

Required: No

Response Syntax

{
   "QueueUrl": "string"
}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

QueueUrl

The URL of the created Amazon SQS queue.

Type: String

Errors

For information about the errors that are common to all actions, see Common Errors.

InvalidAddress

The specified ID is invalid.

HTTP Status Code: 400

InvalidAttributeName

The specified attribute doesn't exist.

HTTP Status Code: 400

InvalidAttributeValue

A queue attribute value is invalid.

HTTP Status Code: 400

InvalidSecurity

The request was not made over HTTPS or did not use SigV4 for signing.

HTTP Status Code: 400

QueueDeletedRecently

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

HTTP Status Code: 400

QueueNameExists

A queue with this name already exists. Amazon SQS returns this error only if the request includes attributes whose values differ from those of the existing queue.

HTTP Status Code: 400

RequestThrottled

The request was denied due to request throttling.

HTTP Status Code: 400

UnsupportedOperation

Error code 400. Unsupported operation.

HTTP Status Code: 400

Examples

The following example query requests create a new queue namedMyQueue. The structure of AUTHPARAMS depends on the signature of the API request. For more information, see Examples of Signed Signature Version 4 Requests in the AWS General Reference.

Example

Using AWS JSON protocol (Default)

Sample Request

POST / HTTP/1.1
Host: sqs.us-east-1.amazonaws.com
X-Amz-Target: AmazonSQS.CreateQueue
X-Amz-Date: <Date>
Content-Type: application/x-amz-json-1.0
Authorization: <AuthParams>
Content-Length: <PayloadSizeBytes>
Connection: Keep-Alive 
{
    "QueueName":"MyQueue",
    "Attributes": {
        "VisibilityTimeout": "40"
    },
    "tags": {
        "QueueType": "Production"
    }
}

Sample Response

HTTP/1.1 200 OK
x-amzn-RequestId: <requestId>
Content-Length: <PayloadSizeBytes>
Date: <Date>
Content-Type: application/x-amz-json-1.0
{
    "QueueUrl":"https://sqs.us-east-1.amazonaws.com/177715257436/MyQueue"
}

Example

Using AWS query protocol

Sample Request

POST / HTTP/1.1
Host: sqs.us-east-1.amazonaws.com
Content-Type: application/x-www-form-urlencoded
X-Amz-Date: <Date>
Authorization: <AuthParams>
Content-Length: <PayloadSizeBytes>
Connection: Keep-Alive
Action=CreateQueue
&QueueName=MyQueue
&Attribute.1.Name=VisibilityTimeout
&Attribute.1.Value=40
&Tag.Key=QueueType
&Tag.Value=Production

Sample Response

HTTP/1.1 200 OK
<?xml version="1.0"?>
<CreateQueueResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
    <CreateQueueResult>
        <QueueUrl>https://sqs.us-east-1.amazonaws.com/177715257436/MyQueue</QueueUrl>
    </CreateQueueResult>
    <ResponseMetadata>
        <RequestId>9b20926c-8b35-5d8e-9559-ce1c22e754dc</RequestId>
    </ResponseMetadata>
</CreateQueueResponse>

Example

The following example creates a delay queue which hides each message from consumers for the first 45 seconds that the message is in the queue by calling the CreateQueue action with the DelaySeconds attribute set to 45 seconds.

Note

Queue URLs and names are case-sensitive.

Sample Request

https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue/
?Action=CreateQueue
&QueueName=MyQueue
&Attribute.1.Name=DelaySeconds
&Attribute.1.Value=45
&Expires=2020-12-20T22%3A52%3A43PST
&Version=2012-11-05
&AUTHPARAMS

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: