| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect1 id="zend.queue.framework">
- <title>Framework</title>
- <para>
- The <classname>Zend_Queue</classname> is a proxy that hides the details
- of the queue services. The queue services are represented by
- <classname>Zend_Queue_Adapter_<service></classname>. For example,
- <classname>Zend_Queue_Adapter_Db</classname> is a queue that will use
- database tables to store and retrieve messages.
- </para>
- <para>
- Below is an example for using database tables for a queuing system:
- </para>
- <programlisting language="php"><![CDATA[
- $options = array(
- 'name' => 'queue1',
- 'driverOptions' => array(
- 'host' => '127.0.0.1',
- 'port' => '3306',
- 'username' => 'queue',
- 'password' => 'queue',
- 'dbname' => 'queue',
- 'type' => 'pdo_mysql'
- )
- );
- // Create a database queue.
- // Zend_Queue will prepend Zend_Queue_Adapter_ to 'Db' for the class name.
- $queue = new Zend_Queue('Db', $options);
- ]]></programlisting>
- <para>
- The <classname>Zend_Queue</classname> constructor will create a
- <classname>Zend_Queue_Adapter_Db</classname> and initialize the adapter
- with the configuration settings.
- </para>
- <para>
- The accepted configuration settings for each adapter are provided
- in the <link linkend="zend.queue.adapters">adapter notes</link>.
- </para>
- <para>
- <classname>Zend_Queue</classname> returns messages using the class
- <classname>Zend_Queue_Message_Iterator</classname>, which is an
- implementation of <acronym>SPL</acronym> <classname>Iterator</classname> and
- <classname>Countable</classname>.
- <classname>Zend_Queue_Message_Iterator</classname> contains an array of
- <classname>Zend_Queue_Message</classname> objects.
- </para>
- <programlisting language="php"><![CDATA[
- $messages = $queue->receive(5);
- foreach ($messages as $i => $message) {
- echo "$i) Message => ", $message->body, "\n";
- }
- ]]></programlisting>
- <para>
- Any exceptions thrown are of class
- <classname>Zend_Queue_Exception</classname>.
- </para>
- <sect2 id="zend.queue.framework.basics">
- <title>Introduction</title>
- <para>
- <classname>Zend_Queue</classname> is a proxy class that represents
- an adapter.
- </para>
- <para>
- The <methodname>send()</methodname>,
- <methodname>count($queue)</methodname>, and
- <methodname>receive()</methodname> methods are employed by each
- adapter to interact with queues.
- </para>
- <para>
- The <methodname>createQueue()</methodname>,
- <methodname>deleteQueue()</methodname> methods are used to manage
- queues.
- </para>
- </sect2>
- <sect2 id="zend.queue.framework.support">
- <title>Commonality among adapters</title>
- <para>
- The queue services supported by <classname>Zend_Queue</classname> do
- not all support the same functions. For example,
- <classname>Zend_Queue_Adapter_Array</classname>,
- <classname>Zend_Queue_Adapter_Db</classname>, support all functions,
- while <classname>Zend_Queue_Adapter_Activemq</classname> does not
- support queue listing, queue deletion, or counting of messages.
- </para>
- <para>
- You can determine what functions are supported by using
- <methodname>Zend_Queue::isSupported()</methodname> or
- <methodname>Zend_Queue::getCapabilities()</methodname>.
- </para>
- <itemizedlist>
- <listitem>
- <para>
- <emphasis><methodname>createQueue()</methodname></emphasis> - create a queue
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis><methodname>deleteQueue()</methodname></emphasis> - delete a queue
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis><methodname>send()</methodname></emphasis> - send a message
- </para>
- <para>
- <methodname>send()</methodname> is not available in all adapters; the
- <classname>Zend_Queue_Adapter_Null</classname> does not
- support <methodname>send()</methodname>.
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis><methodname>receive()</methodname></emphasis> - receive messages
- </para>
- <para>
- <methodname>receive()</methodname> is not available in all adapters;
- the <classname>Zend_Queue_Adapter_Null</classname> does not
- support <methodname>receive()</methodname>.
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis><methodname>deleteMessage()</methodname></emphasis> - delete a
- message
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis><methodname>count()</methodname></emphasis> - count the number of
- messages in a queue
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis><methodname>isExists()</methodname></emphasis> - checks the existence
- of a queue
- </para>
- </listitem>
- </itemizedlist>
- <para>
- <methodname>receive()</methodname> methods are employed by each
- adapter to interact with queues.
- </para>
- <para>
- The <methodname>createQueue()</methodname> and
- <methodname>deleteQueue()</methodname> methods are used to manage
- queues.
- </para>
- </sect2>
- </sect1>
|