PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Queue operations

All messages SQS are stored in queues. A queue has to be created before any message operations. Queue names must be unique under your access key and secret key.

Queue names can contain lowercase letters, digits, periods (.), underscores (_), and dashes (-). No other symbols allowed. Queue names can be a maximum of 80 characters.

  • create() creates a new queue.

  • delete() removes all messages in the queue.

    Example 777. Zend_Service_Amazon_Sqs Queue Removal Example

    <?php
    $sqs 
    = new Zend_Service_Amazon_Sqs($my_aws_key$my_aws_secret_key);
    $queue_url $sqs->create('test_1');
    $sqs->delete($queue_url);

  • count() gets the approximate number of messages in the queue.

    Example 778. Zend_Service_Amazon_Sqs Queue Count Example

    <?php
    $sqs 
    = new Zend_Service_Amazon_Sqs($my_aws_key$my_aws_secret_key);
    $queue_url $sqs->create('test_1');
    $sqs->send($queue_url'this is a test');
    $count $sqs->count($queue_url); // Returns '1'

  • getQueues() returns the list of the names of all queues belonging to the user.

    Example 779. Zend_Service_Amazon_Sqs Queue Listing Example

    <?php
    $sqs 
    = new Zend_Service_Amazon_Sqs($my_aws_key$my_aws_secret_key);
    $list $sqs->getQueues();
    foreach(
    $list as $queue) {
       echo 
    "I have queue $queue\n";
    }

Zend Framework