AdapterInterface.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Interface for common queue operations
  24. *
  25. * @category Zend
  26. * @package Zend_Queue
  27. * @subpackage Adapter
  28. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. interface Zend_Queue_Adapter_AdapterInterface
  32. {
  33. /**
  34. * Constructor
  35. *
  36. * @param array|Zend_Config $options
  37. * @param Zend_Queue $queue
  38. * @return void
  39. */
  40. public function __construct($options, Zend_Queue $queue = null);
  41. /**
  42. * Retrieve queue instance
  43. *
  44. * @return Zend_Queue
  45. */
  46. public function getQueue();
  47. /**
  48. * Set queue instnace
  49. *
  50. * @param Zend_Queue $queue
  51. * @return Zend_Queue_Adapter_AdapterInterface
  52. */
  53. public function setQueue(Zend_Queue $queue);
  54. /**
  55. * Does a queue already exist?
  56. *
  57. * Use isSupported('isExists') to determine if an adapter can test for
  58. * queue existance.
  59. *
  60. * @param string $name Queue name
  61. * @return boolean
  62. */
  63. public function isExists($name);
  64. /**
  65. * Create a new queue
  66. *
  67. * Visibility timeout is how long a message is left in the queue
  68. * "invisible" to other readers. If the message is acknowleged (deleted)
  69. * before the timeout, then the message is deleted. However, if the
  70. * timeout expires then the message will be made available to other queue
  71. * readers.
  72. *
  73. * @param string $name Queue name
  74. * @param integer $timeout Default visibility timeout
  75. * @return boolean
  76. */
  77. public function create($name, $timeout=null);
  78. /**
  79. * Delete a queue and all of its messages
  80. *
  81. * Return false if the queue is not found, true if the queue exists.
  82. *
  83. * @param string $name Queue name
  84. * @return boolean
  85. */
  86. public function delete($name);
  87. /**
  88. * Get an array of all available queues
  89. *
  90. * Not all adapters support getQueues(); use isSupported('getQueues')
  91. * to determine if the adapter supports this feature.
  92. *
  93. * @return array
  94. */
  95. public function getQueues();
  96. /**
  97. * Return the approximate number of messages in the queue
  98. *
  99. * @param Zend_Queue|null $queue
  100. * @return integer
  101. */
  102. public function count(Zend_Queue $queue = null);
  103. /********************************************************************
  104. * Messsage management functions
  105. *********************************************************************/
  106. /**
  107. * Send a message to the queue
  108. *
  109. * @param mixed $message Message to send to the active queue
  110. * @param Zend_Queue|null $queue
  111. * @return Zend_Queue_Message
  112. */
  113. public function send($message, Zend_Queue $queue = null);
  114. /**
  115. * Get messages in the queue
  116. *
  117. * @param integer|null $maxMessages Maximum number of messages to return
  118. * @param integer|null $timeout Visibility timeout for these messages
  119. * @param Zend_Queue|null $queue
  120. * @return Zend_Queue_Message_Iterator
  121. */
  122. public function receive($maxMessages = null, $timeout = null, Zend_Queue $queue = null);
  123. /**
  124. * Delete a message from the queue
  125. *
  126. * Return true if the message is deleted, false if the deletion is
  127. * unsuccessful.
  128. *
  129. * @param Zend_Queue_Message $message
  130. * @return boolean
  131. */
  132. public function deleteMessage(Zend_Queue_Message $message);
  133. /********************************************************************
  134. * Supporting functions
  135. *********************************************************************/
  136. /**
  137. * Returns the configuration options in this adapter.
  138. *
  139. * @return array
  140. */
  141. public function getOptions();
  142. /**
  143. * Return a list of queue capabilities functions
  144. *
  145. * $array['function name'] = true or false
  146. * true is supported, false is not supported.
  147. *
  148. * @return array
  149. */
  150. public function getCapabilities();
  151. /**
  152. * Indicates if a function is supported or not.
  153. *
  154. * @param string $name Function name
  155. * @return boolean
  156. */
  157. public function isSupported($name);
  158. }