Sophie

Sophie

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

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;send()</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->rollback()"
HREF="function.samconnection-rollback.html"><LINK
REL="NEXT"
TITLE="SAMConnection::setDebug()"
HREF="function.samconnection-setdebug.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-rollback.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.samconnection-setdebug.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.samconnection-send"
></A
>SAMConnection-&#62;send()</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN200940"
></A
><P
>    (no version information, might be only in CVS)</P
>SAMConnection-&#62;send()&nbsp;--&nbsp;
   Send a message to a queue or publish an item to a topic.
  </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN200943"
></A
><H2
>说明</H2
>class <B
CLASS="classname"
>SAMConnection</B
> { <BR
></BR
>string <B
CLASS="methodname"
>send</B
> ( string target, SAMMessage msg [, array properties] )<BR
></BR
>}<P
>&#13;   The "send" method is used to send a message to a specific queue or to
   publish to a specific topic. The method returns a correlation id that can
   be used as a selector to identify reply or response messages when these
   are requested.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN200961"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>target</CODE
></DT
><DD
><P
>&#13;       If sending a message, the identity of the queue (queue://queuename)
       or if publishing to a topic the identity of the topic
       (topic://topicname) to which the message is to be delivered.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>msg</CODE
></DT
><DD
><P
>&#13;        The message to be sent or published.
      </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="AEN200980"
></A
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Property name</TH
><TH
>Possible values</TH
></TR
></THEAD
><TBODY
><TR
><TD
>SAM_DELIVERYMODE</TD
><TD
>&#13;            Indicates whether the messaging server should enusre delivery or
            whether it is acceptable for messages to be lost in the case of
            system failures. The value of this property may be set to either
            <TT
CLASS="constant"
><B
>SAM_PERSISTENT</B
></TT
>, to indicate that message
            loss is not acceptable, or 
            <TT
CLASS="constant"
><B
>SAM_NON_PERSISTENT</B
></TT
>, if message loss is
            acceptable. The resulting behaviour of the send will vary
            depending on the capabilities of the messaging server the PHP
            script is currently connected to. If the server does not support
            persistent messages and <TT
CLASS="constant"
><B
>SAM_PERSISTENT</B
></TT
> is
            specified the send request will fail with an error indication
            showing the capability is not available.
           </TD
></TR
><TR
><TD
>SAM_PRIORITY</TD
><TD
>&#13;            A numeric value between 0 and 9 indicating the desired message
            delivery priority. A priority value of 0 indicates the lowest
            priority while 9 indicates highest priority. If no priority is
            specified a default will be assigned which is dependent on the
            messaging server being used.
           </TD
></TR
><TR
><TD
>SAM_CORRELID</TD
><TD
>&#13;            A string to be assigned as a correlation id for this message. If
            no value is given the messaging server may assign a value
            automatically.
           </TD
></TR
><TR
><TD
>SAM_TIMETOLIVE</TD
><TD
>&#13;            A time in milliseconds indicating how long the messaging server
            should retain the message on a queue before discarding it. The
            default value is 0 indicating the message should be retained
            indefinitely.
           </TD
></TR
><TR
><TD
>SAM_WMQ_TARGET_CLIENT</TD
><TD
>&#13;            This property is only valid when using WebSphere MQ and indicates
            whether or not an RFH2 header should be included with the
            message. This option may be set to either 'jms' or 'mq'. The
            default is 'jms' which means that an RFH2 header is included.
            If the value 'mq' is specified then no RFH2 is included with the
            message. 
           </TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN201005"
></A
><H2
>返回值</H2
><P
>&#13;   A correlation id string that can be used in a subsequent receive call as a
   selector to obtain any reply or response that has been requested or <TT
CLASS="constant"
><B
>FALSE</B
></TT
>
   if an error occurred.
  </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
    A correlation id will only be returned for a successful send to a queue
    destination (queue://xxxx) in which case it will reflect the message
    identitiy of the message on the queue. In the case of a send being used
    to publish data to a topic the return value will be <TT
CLASS="constant"
><B
>TRUE</B
></TT
> as no
    correlation id is availabe for return.
   </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN201012"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN201015"
></A
><P
><B
>例 1. Send a message to 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">= new </font><font color="#0000BB">SAMMessage</font><font color="#007700">(</font><font color="#DD0000">'This is a simple text message'</font><font color="#007700">);<br /></font><font color="#0000BB">$correlId </font><font color="#007700">= </font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">send</font><font color="#007700">(</font><font color="#DD0000">'queue://send/test'</font><font color="#007700">, </font><font color="#0000BB">$msg</font><font color="#007700">);<br />if (!</font><font color="#0000BB">$correlId</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// The send failed!<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">echo </font><font color="#DD0000">"Send 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 /><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="AEN201019"
></A
><P
><B
>例 2. Publish a message to a topic</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">= new </font><font color="#0000BB">SAMMessage</font><font color="#007700">(</font><font color="#DD0000">'This is a simple text item'</font><font color="#007700">);<br />if (!</font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">send</font><font color="#007700">(</font><font color="#DD0000">'topic://test'</font><font color="#007700">, </font><font color="#0000BB">$msg</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// The Send failed!<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">echo </font><font color="#DD0000">"Send 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
>
   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN201022"
></A
><P
><B
>例 3. Send a request and receive a response</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">= new </font><font color="#0000BB">SAMMessage</font><font color="#007700">(</font><font color="#DD0000">'This is a simple text message'</font><font color="#007700">);<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">SAM_REPLY_TO </font><font color="#007700">= </font><font color="#DD0000">'queue://receive/test'</font><font color="#007700">;<br /></font><font color="#0000BB">$correlid </font><font color="#007700">= </font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">send</font><font color="#007700">(</font><font color="#DD0000">'queue://send/test'</font><font color="#007700">, </font><font color="#0000BB">$msg</font><font color="#007700">);<br /><br />if (!</font><font color="#0000BB">$correlid</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// The Send failed!<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">echo </font><font color="#DD0000">"Send 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 />} else {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$resp </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">$correlid</font><font color="#007700">));<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN201025"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.samconnection-receive.html"
>SAMConnection-&#62;receive()</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-rollback.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-setdebug.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SAMConnection-&#62;rollback()</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::setDebug()</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>