get_queue_attributes ( $queue_url, $opt )

Gets attributes for the specified queue. The following attributes are supported:

  • All - returns all values.
  • ApproximateNumberOfMessages - returns the approximate number of visible messages in a queue. For more information, see Resources Required to Process Messages in the Amazon SQS Developer Guide.
  • ApproximateNumberOfMessagesNotVisible - returns the approximate number of messages that are not timed-out and not deleted. For more information, see Resources Required to Process Messages in the Amazon SQS Developer Guide.
  • VisibilityTimeout - returns the visibility timeout for the queue. For more information about visibility timeout, see Visibility Timeout in the Amazon SQS Developer Guide.
  • CreatedTimestamp - returns the time when the queue was created (epoch time in seconds).
  • LastModifiedTimestamp - returns the time when the queue was last changed (epoch time in seconds).
  • Policy - returns the queue’s policy.
  • MaximumMessageSize - returns the limit of how many bytes a message can contain before Amazon SQS rejects it.
  • MessageRetentionPeriod - returns the number of seconds Amazon SQS retains a message.
  • QueueArn - returns the queue’s Amazon resource name (ARN).
  • ApproximateNumberOfMessagesDelayed - returns the approximate number of messages that are pending to be added to the queue.
  • DelaySeconds - returns the default delay on the queue in seconds.
  • ReceiveMessageWaitTimeSeconds - returns the time for which a ReceiveMessage call will wait for a message to arrive.

Access

public

Parameters

Parameter

Type

Required

Description

$queue_url

string

Required

The URL of the SQS queue to take action on.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • AttributeName - string|array - Optional - A list of attributes to retrieve information for. Pass a string for a single value, or an indexed array for multiple values.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Get all queue attributes.

// Get queue attributes
$sqs = new AmazonSQS();
$response = $sqs->get_queue_attributes('example-queue');

// Success?
var_dump($response->isOK());
Result:
bool(true)

Get all queue attributes.

// Get queue attributes
$sqs = new AmazonSQS();
$response = $sqs->get_queue_attributes('example-queue', array(
	'AttributeName' => 'All'
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Get specific queue attributes.

// Get queue attributes
$sqs = new AmazonSQS();
$response = $sqs->get_queue_attributes('example-queue', array(
	'AttributeName' => array(
		'ApproximateNumberOfMessages',
		'VisibilityTimeout',
		'CreatedTimestamp',
		'LastModifiedTimestamp',
		'Policy'
	)
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/sqs.class.php | Toggle source view (16 lines) | View on GitHub

public function get_queue_attributes($queue_url, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['QueueUrl'] = $queue_url;
    
    // Optional list (non-map)
    if (isset($opt['AttributeName']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'AttributeName' => (is_array($opt['AttributeName']) ? $opt['AttributeName'] : array($opt['AttributeName']))
        )));
        unset($opt['AttributeName']);
    }

    return $this->authenticate('GetQueueAttributes', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback