Introducción a Zend Framework

 Aprendiendo Zend Framework

Apéndice

 Referencia de Zend Framework


  • Zend_Gdata
  • Zend_Http
  • Zend_InfoCard
  • Zend_Json
  • Zend_Layout
  • Zend_Ldap
  • Zend_Loader
  • Zend_Locale
  • Zend_Log
  • Zend_Mail
  • Zend_Markup
  • Zend_Measure
  • Zend_Memory
  • Zend_Mime
  • Zend_Navigation
  • Zend_Oauth
  • Zend_OpenId
  • Zend_Paginator
  • Zend_Pdf
  • Zend_ProgressBar
  • Zend_Queue
  • Zend_Reflection
  • Zend_Registry
  • Zend_Rest

  • Zend_Search_Lucene
  • Zend_Serializer
  • Zend_Server
  • Zend_Service
  • Zend_Session
  • Zend_Soap
  • Zend_Tag
  • Zend_Test
  • Zend_Text
  • Zend_TimeSync
  • Zend_Tool
  • Zend_Tool_Framework
  • Zend_Tool_Project
  • Zend_Translate
  • Zend_Uri
  • Zend_Validate
  • Zend_Version
  • Zend_View
  • Zend_Wildfire
  • Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Traducción al 26.9% - Actualizado el 2011-11-16 - Revisión 24249 - Versión ZF 1.11.x

    63.37. Zend_Service_WindowsAzure_Storage_Queue

    The Queue service stores messages that may be read by any client who has access to the storage account.

    A queue can contain an unlimited number of messages, each of which can be up to 8 KB in size. Messages are generally added to the end of the queue and retrieved from the front of the queue, although first in/first out (FIFO) behavior is not guaranteed. If you need to store messages larger than 8 KB, you can store message data as a queue or in a table and then store a reference to the data as a message in a queue.

    Queue Storage is offered by Windows Azure as a REST API which is wrapped by the Zend_Service_WindowsAzure_Storage_Queue class in order to provide a native PHP interface to the storage account.

    63.37.1. API Examples

    This topic lists some examples of using the Zend_Service_WindowsAzure_Storage_Queue class. Other features are available in the download package, as well as a detailed API documentation of those features.

    63.37.1.1. Creating a queue

    Using the following code, a queue can be created on development storage.

    Ejemplo 63.197. Creating a queue

    $storageClient = new Zend_Service_WindowsAzure_Storage_Queue();
    $result $storageClient->createQueue('testqueue');

    echo 
    'Queue name is: ' $result->Name;

    63.37.1.2. Deleting a queue

    Using the following code, a queue can be removed from development storage.

    Ejemplo 63.198. Deleting a queue

    $storageClient = new Zend_Service_WindowsAzure_Storage_Queue();
    $storageClient->deleteQueue('testqueue');

    63.37.1.3. Adding a message to a queue

    Using the following code, a message can be added to a queue on development storage. Note that the queue has already been created before.

    Ejemplo 63.199. Adding a message to a queue

    $storageClient = new Zend_Service_WindowsAzure_Storage_Queue();

    // 3600 = time-to-live of the message, if omitted defaults to 7 days
    $storageClient->putMessage('testqueue''This is a test message'3600);

    63.37.1.4. Reading a message from a queue

    Using the following code, a message can be read from a queue on development storage. Note that the queue and message have already been created before.

    Ejemplo 63.200. Reading a message from a queue

    $storageClient = new Zend_Service_WindowsAzure_Storage_Queue();

    // retrieve 10 messages at once
    $messages $storageClient->getMessages('testqueue'10);

    foreach (
    $messages as $message) {
        echo 
    $message->MessageText "\r\n";
    }

    The messages that are read using getMessages() will be invisible in the queue for 30 seconds, after which the messages will re-appear in the queue. To mark a message as processed and remove it from the queue, use the deleteMessage() method.

    Ejemplo 63.201. Marking a message as processed

    $storageClient = new Zend_Service_WindowsAzure_Storage_Queue();

    // retrieve 10 messages at once
    $messages $storageClient->getMessages('testqueue'10);

    foreach (
    $messages as $message) {
        echo 
    $message "\r\n";

        
    // Mark the message as processed
        
    $storageClient->deleteMessage('testqueue'$message);
    }

    63.37.1.5. Check if there are messages in a queue

    Using the following code, a queue can be checked for new messages. Note that the queue and message have already been created before.

    Ejemplo 63.202. Check if there are messages in a queue

    $storageClient = new Zend_Service_WindowsAzure_Storage_Queue();

    // retrieve 10 messages at once
    $messages $storageClient->peekMessages('testqueue'10);

    foreach (
    $messages as $message) {
        echo 
    $message->MessageText "\r\n";
    }

    Note that messages that are read using peekMessages() will not become invisible in the queue, nor can they be marked as processed using the deleteMessage() method. To do this, use getMessages() instead.

    digg delicious meneame google twitter technorati facebook

    Comentarios

    Loading...