<!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>Read one or more messages from a queue without removing it from the queue.</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="samconnection.peek.html">SAMConnection::peek</a></div> <div class="next" style="text-align: right; float: right;"><a href="samconnection.receive.html">SAMConnection::receive</a></div> <div class="up"><a href="ref.sam.html">SAM Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="samconnection.peekall" class="refentry"> <div class="refnamediv"> <h1 class="refname">SAMConnection::peekAll</h1> <p class="verinfo">(PECL sam >= 0.2.0)</p><p class="refpurpose"><span class="refname">SAMConnection::peekAll</span> — <span class="dc-title"> Read one or more messages from a queue without removing it from the queue. </span></p> </div> <div class="refsect1 description" id="refsect1-samconnection.peekall-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><strong>SAMConnection::peekAll</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$target</code></span> [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$properties</code></span> ] )</div> </div> <div class="refsect1 parameters" id="refsect1-samconnection.peekall-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">target</code></em></span> <dd> <p class="para"> The identity of the queue from which messages should be peeked. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">properties</code></em></span> <dd> <p class="para"> An optional associative array of properties describing other parameters to control the peek operation. <table class="doctable informaltable"> <thead> <tr> <th>Property name</th> <th>Possible values</th> </tr> </thead> <tbody class="tbody"> <tr> <td>SAM_CORRELID</td> <td> This is the target correlation id string of messages to be peeked. This would typically have been returned by a "send" request. </td> </tr> <tr> <td>SAM_MESSAGEID</td> <td> This is the message id string of a message which is to be peeked. </td> </tr> </tbody> </table> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-samconnection.peekall-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> This method returns an array of SAMMessage objects or <strong><code>FALSE</code></strong> if an error occurs. </p> </div> <div class="refsect1 examples" id="refsect1-samconnection.peekall-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4526"> <p><strong>Example #1 Retrieve all messages in a queue without removing them</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$msgArray </span><span style="color: #007700">= </span><span style="color: #0000BB">$conn</span><span style="color: #007700">-></span><span style="color: #0000BB">peekAll</span><span style="color: #007700">(</span><span style="color: #DD0000">'queue://receive/test'</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$msgArray</span><span style="color: #007700">) {<br /> foreach ( </span><span style="color: #0000BB">$msgArray </span><span style="color: #007700">as </span><span style="color: #0000BB">$key </span><span style="color: #007700">=> </span><span style="color: #0000BB">$msg</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"Message </span><span style="color: #0000BB">$key</span><span style="color: #DD0000">: body = </span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">body</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /> }<br />} else {<br /> echo </span><span style="color: #DD0000">"PeekAll failed (</span><span style="color: #0000BB">$conn</span><span style="color: #007700">-></span><span style="color: #0000BB">errno</span><span style="color: #DD0000">) </span><span style="color: #0000BB">$conn</span><span style="color: #007700">-></span><span style="color: #0000BB">error</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> <p class="para"> <div class="example" id="example-4527"> <p><strong>Example #2 Retrieve all messages from a queue with a matching correlation id </strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br /> $msgArray </span><span style="color: #007700">= </span><span style="color: #0000BB">$conn</span><span style="color: #007700">-></span><span style="color: #0000BB">peekAll</span><span style="color: #007700">(</span><span style="color: #DD0000">'queue://receive/test'</span><span style="color: #007700">, array(</span><span style="color: #0000BB">SAM_CORRELID </span><span style="color: #007700">=> </span><span style="color: #0000BB">$correlId </span><span style="color: #007700">));<br /> if (</span><span style="color: #0000BB">$msgArray</span><span style="color: #007700">) {<br /><br /> foreach ( </span><span style="color: #0000BB">$msgArray </span><span style="color: #007700">as </span><span style="color: #0000BB">$key </span><span style="color: #007700">=> </span><span style="color: #0000BB">$msg</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"Message </span><span style="color: #0000BB">$key</span><span style="color: #DD0000">: body = </span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">body</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /> }<br /> } else {<br /> echo </span><span style="color: #DD0000">"PeekAll failed (</span><span style="color: #0000BB">$conn</span><span style="color: #007700">-></span><span style="color: #0000BB">errno</span><span style="color: #DD0000">) </span><span style="color: #0000BB">$conn</span><span style="color: #007700">-></span><span style="color: #0000BB">error</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br /> }<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-samconnection.peekall-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="samconnection.peek.html" class="xref">SAMConnection::peek</a></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="samconnection.peek.html">SAMConnection::peek</a></div> <div class="next" style="text-align: right; float: right;"><a href="samconnection.receive.html">SAMConnection::receive</a></div> <div class="up"><a href="ref.sam.html">SAM Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>