Zend_Queue-Framework.xml 5.8 KB

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