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

Receive a message

To receive one or more messages from the queue, use the receiveMessages() method. This method returns a Zend_Cloud_QueueService_MessageSet instance by default, unless configured otherwise. Each element of the MessageSet is an instance of Zend_Cloud_QueueService_Message by default, unless configuired otherwise.

Example 93. Receiving a message

<?php
// Get the first message
$messages $queues->receiveMessages($queueId);
if (
count($messages)) {
    foreach (
$messages as $message) {
        echo 
"Message: " $message->getBody();
        break;
    }
}

// Get two messages
$messages $queues->receiveMessages($queueId2);

When a message is received, it is not visible to other clients. It is not deleted from the queue, however, until the client that has received the message calls the deleteMessage() method. If it is not deleted during the specfied visibility timeout, it will become visible to all other clients again. In other words, all clients will be able to retrieve the message with the receiveMessages() method if the visibility timeout is exceeded.

Zend Framework