1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.queue.framework">
4 <title>Framework</title>
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_<service></classname>. For example,
10 <classname>Zend_Queue_Adapter_Db</classname> is a queue that will use
11 database tables to store and retrieve messages.
15 Below is an example for using database tables for a queuing system:
18 <programlisting language="php"><![CDATA[
21 'driverOptions' => array(
22 'host' => '127.0.0.1',
24 'username' => 'queue',
25 'password' => 'queue',
31 // Create a database queue.
32 // Zend_Queue will prepend Zend_Queue_Adapter_ to 'Db' for the class name.
33 $queue = new Zend_Queue('Db', $options);
37 The <classname>Zend_Queue</classname> constructor will create a
38 <classname>Zend_Queue_Adapter_Db</classname> and initialize the adapter
39 with the configuration settings.
43 The accepted configuration settings for each adapter are provided
44 in the <link linkend="zend.queue.adapters">adapter notes</link>.
48 <classname>Zend_Queue</classname> returns messages using the class
49 <classname>Zend_Queue_Message_Iterator</classname>, which is an
50 implementation of <acronym>SPL</acronym> <classname>Iterator</classname> and
51 <classname>Countable</classname>.
52 <classname>Zend_Queue_Message_Iterator</classname> contains an array of
53 <classname>Zend_Queue_Message</classname> objects.
56 <programlisting language="php"><![CDATA[
57 $messages = $queue->receive(5);
58 foreach ($messages as $i => $message) {
59 echo "$i) Message => ", $message->body, "\n";
64 Any exceptions thrown are of class
65 <classname>Zend_Queue_Exception</classname>.
68 <sect2 id="zend.queue.framework.basics">
69 <title>Introduction</title>
72 <classname>Zend_Queue</classname> is a proxy class that represents
77 The <methodname>send()</methodname>,
78 <methodname>count($queue)</methodname>, and
79 <methodname>receive()</methodname> methods are employed by each
80 adapter to interact with queues.
84 The <methodname>createQueue()</methodname>,
85 <methodname>deleteQueue()</methodname> methods are used to manage
90 <sect2 id="zend.queue.framework.support">
91 <title>Commonality among adapters</title>
94 The queue services supported by <classname>Zend_Queue</classname> do
95 not all support the same functions. For example,
96 <classname>Zend_Queue_Adapter_Array</classname>,
97 <classname>Zend_Queue_Adapter_Db</classname>, support all functions,
98 while <classname>Zend_Queue_Adapter_Activemq</classname> does not
99 support queue listing, queue deletion, or counting of messages.
103 You can determine what functions are supported by using
104 <methodname>Zend_Queue::isSupported()</methodname> or
105 <methodname>Zend_Queue::getCapabilities()</methodname>.
111 <emphasis><methodname>createQueue()</methodname></emphasis> - create a queue
117 <emphasis><methodname>deleteQueue()</methodname></emphasis> - delete a queue
123 <emphasis><methodname>send()</methodname></emphasis> - send a message
127 <methodname>send()</methodname> is not available in all adapters; the
128 <classname>Zend_Queue_Adapter_Null</classname> does not
129 support <methodname>send()</methodname>.
135 <emphasis><methodname>receive()</methodname></emphasis> - receive messages
139 <methodname>receive()</methodname> is not available in all adapters;
140 the <classname>Zend_Queue_Adapter_Null</classname> does not
141 support <methodname>receive()</methodname>.
147 <emphasis><methodname>deleteMessage()</methodname></emphasis> - delete a
154 <emphasis><methodname>count()</methodname></emphasis> - count the number of
161 <emphasis><methodname>isExists()</methodname></emphasis> - checks the existence
168 <methodname>receive()</methodname> methods are employed by each
169 adapter to interact with queues.
173 The <methodname>createQueue()</methodname> and
174 <methodname>deleteQueue()</methodname> methods are used to manage