GetQueueAttributes#

Description#

Returns the attributes of the specified queue.

Request Syntax#

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

{
    "QueueUrl": "string",
    "AttributeNames": [
        "string"
    ]
}

Request Parameters#

Required parameters#

  • QueueUrl — The queue URL.

    • Type: String

    • Required: Yes

Optional parameters#

  • AttributeNames — The list of names of the attributes being requested. If no name is specified or if All is specified, all attributes are returned.

    • Type: Array of strings

    • Required: No

Supported attributes#

  • ApproximateNumberOfMessages — The approximate number of messages that can be received from the queue.

  • ApproximateNumberOfMessagesDelayed — The approximate number of messages that are delayed and cannot be read.

  • ApproximateNumberOfMessagesNotVisible — The approximate number of messages under processing (i.e. those that are received but not yet deleted or whose visibility timeout has not expired yet).

  • CreatedTimestamp — The queue creation time in the Unix epoch format.

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

  • LastModifiedTimestamp — The time of the last modification of the queue attributes in the Unix epoch format.

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

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

  • QueueArn — The queue ARN.

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

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

Response Syntax#

HTTP/1.1 200
Content-type: application/json

{
    "Attributes": {
        "string": "string"
    }
}

Response Elements#

  • Attributes — The queue attributes.

    • Type: String map

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.get_queue_attributes(
     QueueUrl='https://sqs.ru-msk.k2.cloud/123456789012/my-queue',
     AttributeNames=['All']
 )

 for attr_name, attr_value in response['Attributes'].items():
     print(f"{attr_name}: {attr_value}")
boto3 - Specific Attributes
 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.get_queue_attributes(
     QueueUrl='https://sqs.ru-msk.k2.cloud/123456789012/my-queue',
     AttributeNames=[
         'ApproximateNumberOfMessages',
         'VisibilityTimeout'
     ]
 )

 print(response['Attributes'])
aws-cli
 aws sqs --endpoint https://sqs.ru-msk.k2.cloud/ get-queue-attributes \\
     --queue-url https://sqs.ru-msk.k2.cloud/123456789012/my-queue \\
     --attribute-names All