CreateQueue#

Description#

Creates a new standard queue. When creating the queue, one or more attributes can be passed.

Should a queue with the specified name already exist, SQS returns a success if the attributes passed in the request match those of an existing queue. Otherwise, an error is returned.

Request Syntax#

POST / HTTP/1.1
Content-type: application/json

{
    "Name": "string",
    "Attributes": {
        "VisibilityTimeout": "string",
        "DelaySeconds": "string",
        "MaximumMessageSize": "string",
        "MessageRetentionPeriod": "string",
        "ReceiveMessageWaitTimeSeconds": "string",

    }
}

Request Parameters#

Required parameters#

  • Name — The new queue name.

    • Type: String

    • Required: Yes

    • Constraints: The name must meet the following requirements:
      • Length: 1-80 characters

      • Valid characters: Letters, digits, hyphens (-), and underscores (_)

Optional parameters#

  • Attributes — The queue attributes with values.

    • Type: Object

    • Required: No

Supported attributes#

  • DelaySeconds — The time (in seconds) for which delivery of all messages in the queue is delayed.

    • Type: String

    • Required: No

    • Range: From 0 to 900 (15 minutes)

    • Default value: 0

  • MaximumMessageSize — The maximum message size (in bytes).

    • Type: String

    • Required: No

    • Range: 1024 to 262144

    • Default value: 1048576

  • MessageRetentionPeriod — The time (in seconds) during which SQS retains a message.

    • Type: String

    • Required: No

    • Range: 60 to 1209600 (14 days)

    • Default value: 345600 (4 days)

  • ReceiveMessageWaitTimeSeconds — The wait time (in seconds) for a long polling mode.

    • Type: String

    • Required: No

    • Range: 2 to 20

    • Default value: 0

  • VisibilityTimeout — The time (in seconds) during which a message remains invisible after being received.

    • Type: String

    • Required: No

    • Range: 0 to 43,200 (12 hours)

    • Default value: 30

Response Syntax#

HTTP/1.1 200
Content-type: application/json

{
    "Name": "string",
    "Url": "string"
}

Response Elements#

  • Name — The created queue name.

    • Type: String

  • Url — The created queue URL.

    • Type: String

Errors#

  • InvalidParameterValue — The parameter value is invalid.

  • QueueDeletedRecently — A queue with the same name has been deleted recently.

  • QueueNameExists — A queue with the same name already exists and has different attributes.

Examples#

boto3
 import boto3

 session = boto3.Session(
    aws_access_key_id="<AWS_ACCESS_KEY_ID>",
    aws_secret_access_key="<AWS_SECRET_ACCESS_KEY>",
    region_name="",
 )

 sqs_client = session.client(
    'sqs',
    endpoint_url='https://sqs.ru-msk.k2.cloud/'
 )

 response = sqs_client.create_queue(
     QueueName='my-standard-queue',
     Attributes={
         'VisibilityTimeout': '60',
         'MessageRetentionPeriod': '86400'
     }
 )

 print(f"Queue: {response['QueueUrl']}")
aws-cli
 aws sqs --endpoint https://sqs.ru-msk.k2.cloud/ create-queue \\
     --queue-name my-standard-queue \\
     --attributes VisibilityTimeout=60,MessageRetentionPeriod=86400