Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 9439

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>SAMConnection-&#62;receive()</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="SAM - Simple Asynchronous Messaging"
HREF="ref.sam.html"><LINK
REL="PREVIOUS"
TITLE="SAMConnection->peekAll()"
HREF="function.samconnection-peekall.html"><LINK
REL="NEXT"
TITLE="SAMConnection->remove()"
HREF="function.samconnection-remove.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.samconnection-peekall.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.samconnection-remove.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.samconnection-receive"
></A
>SAMConnection-&#62;receive()</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN200779"
></A
><P
>    (no version information, might be only in CVS)</P
>SAMConnection-&#62;receive()&nbsp;--&nbsp;
   Receive a message from a queue or subscription.
  </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN200782"
></A
><H2
>说明</H2
>class <B
CLASS="classname"
>SAMConnection</B
> { <BR
></BR
>SAMMessage <B
CLASS="methodname"
>receive</B
> ( string target [, array properties] )<BR
></BR
>}</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN200796"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>target</CODE
></DT
><DD
><P
>&#13;       The identity of the queue, topic or subscription from which to receive
       the message.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>properties</CODE
></DT
><DD
><P
>&#13;       An optional associative array of properties describing other
       parameters to control the receive operation.
       <DIV
CLASS="informaltable"
><P
></P
><A
NAME="AEN200810"
></A
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Property name</TH
><TH
>Possible values</TH
></TR
></THEAD
><TBODY
><TR
><TD
>SAM_CORRELID</TD
><TD
>&#13;            Used to request selection of the message to receive based upon
            the correlation id string of the message.
           </TD
></TR
><TR
><TD
>SAM_MESSAGEID</TD
><TD
>&#13;            Used to request selection of the message to receive based upon
            the message id string of the message.
           </TD
></TR
><TR
><TD
>SAM_WAIT</TD
><TD
>&#13;            Timeout value in milliseconds to control how long the request
            should block waiting to receive a message before returning with
            a failure if no message is available on the queue or topic. The
            default value is 0 meaning wait indefinitely and should be used
            with caution as the request may wait until the overall PHP script
            processing time limit has expired if no message becomes available.
           </TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN200826"
></A
><H2
>返回值</H2
><P
>&#13;   This method returns a SAMMessage object or <TT
CLASS="constant"
><B
>FALSE</B
></TT
> if an error occurs.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN200830"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN200833"
></A
><P
><B
>例 1. Receiving a message from a queue</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$msg </font><font color="#007700">= </font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">receive</font><font color="#007700">(</font><font color="#DD0000">'queue://receive/test'</font><font color="#007700">);<br /><br />if (!</font><font color="#0000BB">$msg</font><font color="#007700">) {<br />&nbsp;&nbsp;</font><font color="#FF8000">// The receive failed!<br />&nbsp;&nbsp;</font><font color="#007700">echo </font><font color="#DD0000">"Receive failed ($conn</font><font color="#007700">-&gt;</font><font color="#DD0000">errno) $conn</font><font color="#007700">-&gt;</font><font color="#DD0000">error"</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN200837"
></A
><P
><B
>例 2. Receiving a message from a queue with options</B
></P
><P
>&#13;     In this example the SAM_CORRELID option is used to specify a correlation
     id string to be used to identify the message to receive. A wait timeout
     of 10 seconds is also specified.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$msg </font><font color="#007700">= </font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">receive</font><font color="#007700">(</font><font color="#DD0000">'queue://receive/test'</font><font color="#007700">, array(</font><font color="#0000BB">SAM_CORRELID </font><font color="#007700">=&gt; </font><font color="#0000BB">$token</font><font color="#007700">, </font><font color="#0000BB">SAM_WAIT </font><font color="#007700">=&gt; </font><font color="#0000BB">10000</font><font color="#007700">));<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN200842"
></A
><P
><B
>例 3. Receiving a message from a subscription</B
></P
><P
>&#13;     In this example we show how to receive a message from a subscription id.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$msg </font><font color="#007700">= </font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">receive</font><font color="#007700">(</font><font color="#0000BB">$subscriptionName</font><font color="#007700">);<br /><br />if (!</font><font color="#0000BB">$msg</font><font color="#007700">) {<br />&nbsp;&nbsp;</font><font color="#FF8000">// The receive failed!<br />&nbsp;&nbsp;</font><font color="#007700">echo </font><font color="#DD0000">"Receive failed ($conn</font><font color="#007700">-&gt;</font><font color="#DD0000">errno) $conn</font><font color="#007700">-&gt;</font><font color="#DD0000">error"</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>&#13;     Please note that $subscriptionName is a subscription id returned from an
     earlier subscribe call.
    </P
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN200847"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.samconnection-send.html"
>SAMConnection-&#62;send()</A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.samconnection-peekall.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.samconnection-remove.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SAMConnection-&#62;peekAll()</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.sam.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SAMConnection-&#62;remove()</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>