get_queue_size ( $queue_url )

Returns the approximate number of messages in the queue.

Access

public

Parameters

Parameter

Type

Required

Description

$queue_url

string

Required

The queue URL to perform the action on. Retrieved when the queue is first created.

Returns

Type

Description

mixed

The Approximate number of messages in the queue as an integer. If the queue doesn’t exist, it returns the entire CFResponse object.

Examples

Get the (approximate) number of messages in the queue.

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

// Success?
var_dump($response);

Source

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

public function get_queue_size($queue_url)
{
    $response = $this->get_queue_attributes($queue_url, array(
        'AttributeName' => 'ApproximateNumberOfMessages'
    ));

    if (!$response->isOK())
    {
        return $response;
    }

    return (integer) $response->body->Value(0);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback