<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Retrieve the next message from the queue.</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="amqpqueue.delete.html">AMQPQueue::delete</a></div> <div class="next" style="text-align: right; float: right;"><a href="amqpqueue.getargument.html">AMQPQueue::getArgument</a></div> <div class="up"><a href="class.amqpqueue.html">AMQPQueue</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="amqpqueue.get" class="refentry"> <div class="refnamediv"> <h1 class="refname">AMQPQueue::get</h1> <p class="verinfo">(PECL amqp >= Unknown)</p><p class="refpurpose"><span class="refname">AMQPQueue::get</span> — <span class="dc-title">Retrieve the next message from the queue.</span></p> </div> <div class="refsect1 description" id="refsect1-amqpqueue.get-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>AMQPQueue::get</strong></span> ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = ini_get("amqp.auto_ack")</span></span> ] )</div> <p class="para rdfs-comment"> Retrieve the next available message from the queue. If no messages are present in the queue, this function will return <strong><code>FALSE</code></strong> immediately. This is a non blocking alternative to the <span class="methodname"><a href="amqpqueue.consume.html" class="methodname">AMQPQueue::consume()</a></span> method. </p> <p class="para"> Currently, the only supported flag for the <em><code class="parameter">flags</code></em> parameter is <strong><code>AMQP_AUTOACK</code></strong>. If this flag is passed in, then the message returned will automatically be marked as acknowledged by the broker as soon as the frames are sent to the client. </p> </div> <div class="refsect1 parameters" id="refsect1-amqpqueue.get-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">flags</code></em></span> <dd> <p class="para"> A bitmask of supported flags for the method call. Currently, the only the supported flag is <strong><code>AMQP_AUTOACK</code></strong>. If this value is not provided, it will use the value of <em>amqp.auto_ack</em>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-amqpqueue.get-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> An instance of <a href="class.amqpenvelope.html" class="classname">AMQPEnvelope</a> representing the message pulled from the queue, or <strong><code>FALSE</code></strong>. </p> </div> <div class="refsect1 examples" id="refsect1-amqpqueue.get-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4202"> <p><strong>Example #1 <span class="methodname"><strong>AMQPQueue::get()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br /> </span><span style="color: #FF8000">/* Create a connection using all default credentials: */<br /> </span><span style="color: #0000BB">$connection </span><span style="color: #007700">= new </span><span style="color: #0000BB">AMQPConnection</span><span style="color: #007700">();<br /> </span><span style="color: #0000BB">$connection</span><span style="color: #007700">-></span><span style="color: #0000BB">connect</span><span style="color: #007700">();<br /><br /> </span><span style="color: #0000BB">$channel </span><span style="color: #007700">= new </span><span style="color: #0000BB">AMQPChannel</span><span style="color: #007700">(</span><span style="color: #0000BB">$connection</span><span style="color: #007700">);<br /><br /> </span><span style="color: #FF8000">/* create a queue object */<br /> </span><span style="color: #0000BB">$queue </span><span style="color: #007700">= new </span><span style="color: #0000BB">AMQPQueue</span><span style="color: #007700">(</span><span style="color: #0000BB">$channel</span><span style="color: #007700">);<br /><br /> </span><span style="color: #FF8000">//declare the queue<br /> </span><span style="color: #0000BB">$queue</span><span style="color: #007700">-></span><span style="color: #0000BB">declare</span><span style="color: #007700">(</span><span style="color: #DD0000">'myqueue'</span><span style="color: #007700">);<br /><br /> </span><span style="color: #FF8000">//get the message<br /> </span><span style="color: #0000BB">$message </span><span style="color: #007700">= </span><span style="color: #0000BB">$queue</span><span style="color: #007700">-></span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #0000BB">AMQP_AUTOACK</span><span style="color: #007700">);<br /><br /> echo </span><span style="color: #0000BB">$message</span><span style="color: #007700">-></span><span style="color: #0000BB">getBody</span><span style="color: #007700">();<br /><br /> </span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="amqpqueue.delete.html">AMQPQueue::delete</a></div> <div class="next" style="text-align: right; float: right;"><a href="amqpqueue.getargument.html">AMQPQueue::getArgument</a></div> <div class="up"><a href="class.amqpqueue.html">AMQPQueue</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>