mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Add examples to AMQPQueue::get and AMQPQueue::ack documentation.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@315574 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
dde7df4766
commit
fa1ad00f00
2 changed files with 100 additions and 0 deletions
|
@ -50,6 +50,75 @@
|
|||
&return.success;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><methodname>AMQPQueue::ack</methodname> example with <methodname>AMQPQueue::get</methodname></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
/* Create a connection using all default credentials: */
|
||||
$connection = new AMQPConnection();
|
||||
$connection->connect();
|
||||
|
||||
/* create a queue object */
|
||||
$queue = new AMQPQueue($connection);
|
||||
|
||||
//declare the queue
|
||||
$queue->declare('myqueue');
|
||||
|
||||
//get the next message, but don't mark it as delivered
|
||||
$message = $queue->get(AMQP_NOACK);
|
||||
|
||||
echo $message['msg'];
|
||||
|
||||
//acknowledge the message as received
|
||||
$queue->ack($message['delivery_tag']);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title><methodname>AMQPQueue::ack</methodname> example with <methodname>AMQPQueue::consume</methodname></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
/* Create a connection using all default credentials: */
|
||||
$connection = new AMQPConnection();
|
||||
$connection->connect();
|
||||
|
||||
/* create a queue object */
|
||||
$queue = new AMQPQueue($connection);
|
||||
|
||||
//declare the queue
|
||||
$queue->declare('myqueue');
|
||||
|
||||
$options = array(
|
||||
'min' => 1,
|
||||
'max' => 10,
|
||||
'ack' => false
|
||||
);
|
||||
|
||||
//get the messages, but don't mark them as delivered
|
||||
$messages = $queue->consume($options);
|
||||
|
||||
foreach ($messages as $message) {
|
||||
echo $message['message_body'];
|
||||
//acknowledge the message as received
|
||||
$queue->ack($message['delivery_tag']);
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -48,6 +48,37 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><methodname>AMQPQueue::get</methodname> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
/* Create a connection using all default credentials: */
|
||||
$connection = new AMQPConnection();
|
||||
$connection->connect();
|
||||
|
||||
/* create a queue object */
|
||||
$queue = new AMQPQueue($connection);
|
||||
|
||||
//declare the queue
|
||||
$queue->declare('myqueue');
|
||||
|
||||
//get the next message
|
||||
$message = $queue->get();
|
||||
|
||||
echo $message['msg'];
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
Loading…
Reference in a new issue