Zend_Queue-Framework.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.queue.framework">
  4. <title>Framework</title>
  5. <para>
  6. The <classname>Zend_Queue</classname> is a proxy that hides the details
  7. of the queue services. The queue services are represented by
  8. <classname>Zend_Queue_Adapter_&lt;service&gt;</classname>. For example,
  9. <classname>Zend_Queue_Adapter_Db</classname> is a queue that will use
  10. database tables to store and retrieve messages.
  11. </para>
  12. <para>
  13. Below is an example for using database tables for a queuing system:
  14. </para>
  15. <programlisting language="php"><![CDATA[
  16. $options = array(
  17. 'name' => 'queue1',
  18. 'driverOptions' => array(
  19. 'host' => '127.0.0.1',
  20. 'port' => '3306',
  21. 'username' => 'queue',
  22. 'password' => 'queue',
  23. 'dbname' => 'queue',
  24. 'type' => 'pdo_mysql'
  25. )
  26. );
  27. // Create a database queue.
  28. // Zend_Queue will prepend Zend_Queue_Adapter_ to 'Db' for the class name.
  29. $queue = new Zend_Queue('Db', $options);
  30. ]]></programlisting>
  31. <para>
  32. The <classname>Zend_Queue</classname> constructor will create a
  33. <classname>Zend_Queue_Adapter_Db</classname> and initialize the adapter
  34. with the configuration settings.
  35. </para>
  36. <para>
  37. The accepted configuration settings for each adapter are provided
  38. in the <link linkend="zend.queue.adapters">adapter notes</link>.
  39. </para>
  40. <para>
  41. <classname>Zend_Queue</classname> returns messages using the class
  42. <classname>Zend_Queue_Message_Iterator</classname>, which is an
  43. implementation of <acronym>SPL</acronym> <classname>Iterator</classname> and
  44. <classname>Countable</classname>.
  45. <classname>Zend_Queue_Message_Iterator</classname> contains an array of
  46. <classname>Zend_Queue_Message</classname> objects.
  47. </para>
  48. <programlisting language="php"><![CDATA[
  49. $messages = $queue->receive(5);
  50. foreach ($messages as $i => $message) {
  51. echo "$i) Message => ", $message->body, "\n";
  52. }
  53. ]]></programlisting>
  54. <para>
  55. Any exceptions thrown are of class
  56. <classname>Zend_Queue_Exception</classname>.
  57. </para>
  58. <sect2 id="zend.queue.framework.basics">
  59. <title>Introduction</title>
  60. <para>
  61. <classname>Zend_Queue</classname> is a proxy class that represents
  62. an adapter.
  63. </para>
  64. <para>
  65. The <methodname>send()</methodname>,
  66. <methodname>count($queue)</methodname>, and
  67. <methodname>receive()</methodname> methods are employed by each
  68. adapter to interact with queues.
  69. </para>
  70. <para>
  71. The <methodname>createQueue()</methodname>,
  72. <methodname>deleteQueue()</methodname> methods are used to manage
  73. queues.
  74. </para>
  75. </sect2>
  76. <sect2 id="zend.queue.framework.support">
  77. <title>Commonality among adapters</title>
  78. <para>
  79. The queue services supported by <classname>Zend_Queue</classname> do
  80. not all support the same functions. For example,
  81. <classname>Zend_Queue_Adapter_Array</classname>,
  82. <classname>Zend_Queue_Adapter_Db</classname>, support all functions,
  83. while <classname>Zend_Queue_Adapter_Activemq</classname> does not
  84. support queue listing, queue deletion, or counting of messages.
  85. </para>
  86. <para>
  87. You can determine what functions are supported by using
  88. <methodname>Zend_Queue::isSupported()</methodname> or
  89. <methodname>Zend_Queue::getCapabilities()</methodname>.
  90. </para>
  91. <itemizedlist>
  92. <listitem>
  93. <para>
  94. <emphasis><methodname>createQueue()</methodname></emphasis> - create a queue
  95. </para>
  96. </listitem>
  97. <listitem>
  98. <para>
  99. <emphasis><methodname>deleteQueue()</methodname></emphasis> - delete a queue
  100. </para>
  101. </listitem>
  102. <listitem>
  103. <para>
  104. <emphasis><methodname>send()</methodname></emphasis> - send a message
  105. </para>
  106. <para>
  107. <methodname>send()</methodname> is not available in all adapters; the
  108. <classname>Zend_Queue_Adapter_Null</classname> does not
  109. support <methodname>send()</methodname>.
  110. </para>
  111. </listitem>
  112. <listitem>
  113. <para>
  114. <emphasis><methodname>receive()</methodname></emphasis> - receive messages
  115. </para>
  116. <para>
  117. <methodname>receive()</methodname> is not available in all adapters;
  118. the <classname>Zend_Queue_Adapter_Null</classname> does not
  119. support <methodname>receive()</methodname>.
  120. </para>
  121. </listitem>
  122. <listitem>
  123. <para>
  124. <emphasis><methodname>deleteMessage()</methodname></emphasis> - delete a
  125. message
  126. </para>
  127. </listitem>
  128. <listitem>
  129. <para>
  130. <emphasis><methodname>count()</methodname></emphasis> - count the number of
  131. messages in a queue
  132. </para>
  133. </listitem>
  134. <listitem>
  135. <para>
  136. <emphasis><methodname>isExists()</methodname></emphasis> - checks the existence
  137. of a queue
  138. </para>
  139. </listitem>
  140. </itemizedlist>
  141. <para>
  142. <methodname>receive()</methodname> methods are employed by each
  143. adapter to interact with queues.
  144. </para>
  145. <para>
  146. The <methodname>createQueue()</methodname> and
  147. <methodname>deleteQueue()</methodname> methods are used to manage
  148. queues.
  149. </para>
  150. </sect2>
  151. </sect1>