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

    56.5. Customizing Zend_Queue

    56.5.1. Creating your own adapter

    Zend_Queue will accept any adapter that implements Zend_Queue_Adapter_AdapterAbstract. You can create your own adapter by extending one of the existing adapters, or the abstract class Zend_Queue_Adapter_AdapterAbstract. I suggest reviewing Zend_Queue_Adapter_Array as this adapter is the easiest to conceptualize.

    class Custom_DbForUpdate extends Zend_Queue_Adapter_Db
    {
        
    /**
         * @see code in tests/Zend/Queue/Custom/DbForUpdate.php
         *
         * Custom_DbForUpdate uses the SELECT ... FOR UPDATE to find it's rows.
         * this is more likely to produce the wanted rows than the existing code.
         *
         * However, not all databases have SELECT ... FOR UPDATE as a feature.
         *
         * Note: this was later converted to be an option for Zend_Queue_Adapter_Db
         *
         * This code still serves as a good example.
         */
    }

    $options = array(
        
    'name'          => 'queue1',
        
    'driverOptions' => array(
            
    'host'      => '127.0.0.1',
            
    'port'      => '3306',
            
    'username'  => 'queue',
            
    'password'  => 'queue',
            
    'dbname'    => 'queue',
            
    'type'      => 'pdo_mysql'
        
    )
    );

    $adapter = new Custom_DbForUpdate($options);
    $queue = new Zend_Queue($adapter$options);

    You can also change the adapter on the fly as well.

    $adapter = new MyCustom_Adapter($options);
    $queue   = new Zend_Queue($options);
    $queue->setAdapter($adapter);
    echo 
    "Adapter: "get_class($queue->getAdapter()), "\n";

    or

    $options = array(
        
    'name'           => 'queue1',
        
    'namespace'      => 'Custom',
        
    'driverOptions'  => array(
            
    'host'       => '127.0.0.1',
            
    'port'       => '3306',
            
    'username'   => 'queue',
            
    'password'   => 'queue',
            
    'dbname'     => 'queue',
            
    'type'       => 'pdo_mysql'
        
    )
    );
    $queue = new Zend_Queue('DbForUpdate'$config); // loads Custom_DbForUpdate

    56.5.2. Creating your own message class

    Zend_Queue will also accept your own message class. Our variables start with an underscore. For example:

    class Zend_Queue_Message
    {
        protected 
    $_data = array();
    }

    You can extend the existing messaging class. See the example code in tests/Zend/Queue/Custom/Message.php.

    56.5.3. Creating your own message iterator class

    Zend_Queue will also accept your own message iterator class. The message iterator class is used to return messages from Zend_Queue_Adapter_Abstract::recieve(). Zend_Queue_Abstract::receive() should always return a container class like Zend_Queue_Message_Iterator, even if there is only one message.

    See the example filename in tests/Zend/Queue/Custom/Messages.php.

    56.5.4. Creating your own queue class

    Zend_Queue can also be overloaded easily.

    See the example filename in tests/Zend/Queue/Custom/Queue.php.

    digg delicious meneame google twitter technorati facebook

    Comentarios

    Loading...