web/lib/Zend/Queue/Adapter/AdapterInterface.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Queue
       
    17  * @subpackage Adapter
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: AdapterInterface.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 /**
       
    24  * Interface for common queue operations
       
    25  *
       
    26  * @category   Zend
       
    27  * @package    Zend_Queue
       
    28  * @subpackage Adapter
       
    29  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    30  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    31  */
       
    32 interface Zend_Queue_Adapter_AdapterInterface
       
    33 {
       
    34     /**
       
    35      * Constructor
       
    36      *
       
    37      * @param  array|Zend_Config $options
       
    38      * @param  Zend_Queue $queue
       
    39      * @return void
       
    40      */
       
    41     public function __construct($options, Zend_Queue $queue = null);
       
    42 
       
    43     /**
       
    44      * Retrieve queue instance
       
    45      *
       
    46      * @return Zend_Queue
       
    47      */
       
    48     public function getQueue();
       
    49 
       
    50     /**
       
    51      * Set queue instnace
       
    52      *
       
    53      * @param  Zend_Queue $queue
       
    54      * @return Zend_Queue_Adapter_AdapterInterface
       
    55      */
       
    56     public function setQueue(Zend_Queue $queue);
       
    57 
       
    58     /**
       
    59      * Does a queue already exist?
       
    60      *
       
    61      * Use isSupported('isExists') to determine if an adapter can test for
       
    62      * queue existance.
       
    63      *
       
    64      * @param  string $name Queue name
       
    65      * @return boolean
       
    66      */
       
    67     public function isExists($name);
       
    68 
       
    69     /**
       
    70      * Create a new queue
       
    71      *
       
    72      * Visibility timeout is how long a message is left in the queue
       
    73      * "invisible" to other readers.  If the message is acknowleged (deleted)
       
    74      * before the timeout, then the message is deleted.  However, if the
       
    75      * timeout expires then the message will be made available to other queue
       
    76      * readers.
       
    77      *
       
    78      * @param  string  $name Queue name
       
    79      * @param  integer $timeout Default visibility timeout
       
    80      * @return boolean
       
    81      */
       
    82     public function create($name, $timeout=null);
       
    83 
       
    84     /**
       
    85      * Delete a queue and all of its messages
       
    86      *
       
    87      * Return false if the queue is not found, true if the queue exists.
       
    88      *
       
    89      * @param  string $name Queue name
       
    90      * @return boolean
       
    91      */
       
    92     public function delete($name);
       
    93 
       
    94     /**
       
    95      * Get an array of all available queues
       
    96      *
       
    97      * Not all adapters support getQueues(); use isSupported('getQueues')
       
    98      * to determine if the adapter supports this feature.
       
    99      *
       
   100      * @return array
       
   101      */
       
   102     public function getQueues();
       
   103 
       
   104     /**
       
   105      * Return the approximate number of messages in the queue
       
   106      *
       
   107      * @param  Zend_Queue|null $queue
       
   108      * @return integer
       
   109      */
       
   110     public function count(Zend_Queue $queue = null);
       
   111 
       
   112     /********************************************************************
       
   113      * Messsage management functions
       
   114      *********************************************************************/
       
   115 
       
   116     /**
       
   117      * Send a message to the queue
       
   118      *
       
   119      * @param  mixed $message Message to send to the active queue
       
   120      * @param  Zend_Queue|null $queue
       
   121      * @return Zend_Queue_Message
       
   122      */
       
   123     public function send($message, Zend_Queue $queue = null);
       
   124 
       
   125     /**
       
   126      * Get messages in the queue
       
   127      *
       
   128      * @param  integer|null $maxMessages Maximum number of messages to return
       
   129      * @param  integer|null $timeout Visibility timeout for these messages
       
   130      * @param  Zend_Queue|null $queue
       
   131      * @return Zend_Queue_Message_Iterator
       
   132      */
       
   133     public function receive($maxMessages = null, $timeout = null, Zend_Queue $queue = null);
       
   134 
       
   135     /**
       
   136      * Delete a message from the queue
       
   137      *
       
   138      * Return true if the message is deleted, false if the deletion is
       
   139      * unsuccessful.
       
   140      *
       
   141      * @param  Zend_Queue_Message $message
       
   142      * @return boolean
       
   143      */
       
   144     public function deleteMessage(Zend_Queue_Message $message);
       
   145 
       
   146     /********************************************************************
       
   147      * Supporting functions
       
   148      *********************************************************************/
       
   149 
       
   150     /**
       
   151      * Returns the configuration options in this adapter.
       
   152      *
       
   153      * @return array
       
   154      */
       
   155     public function getOptions();
       
   156 
       
   157     /**
       
   158      * Return a list of queue capabilities functions
       
   159      *
       
   160      * $array['function name'] = true or false
       
   161      * true is supported, false is not supported.
       
   162      *
       
   163      * @return array
       
   164      */
       
   165     public function getCapabilities();
       
   166 
       
   167     /**
       
   168      * Indicates if a function is supported or not.
       
   169      *
       
   170      * @param  string $name Function name
       
   171      * @return boolean
       
   172      */
       
   173     public function isSupported($name);
       
   174 }