Sophie

Sophie

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

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
>SAM - Simple Asynchronous Messaging</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="函数参考"
HREF="funcref.html"><LINK
REL="PREVIOUS"
TITLE="runkit_superglobals"
HREF="function.runkit-superglobals.html"><LINK
REL="NEXT"
TITLE="SAMConnection->commit()"
HREF="function.samconnection-commit.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="reference"
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.runkit-superglobals.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.samconnection-commit.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.sam"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>CXL. SAM - Simple Asynchronous Messaging</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN199874"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="sam.intro"
>简介</A
></H1
><P
>&#13;     This extension provides access to the functionality of messaging and
     queueing systems, such as the IBM WebSphere MQSeries family of products,
     from PHP scripts. The interface is designed to make it extremely simple
     to do the more commonly required tasks such as deliver simple text
     messages to queues while still allowing skilled users to do more complex
     messaging operations. For many users the complexities of setting up
     numerous options can be simply ignored.
    </P
><P
>&#13;     The SAM extension is a framework that provides a very simple API that can be used to
     access a number of messaging middleware systems. Currently the package
     includes built-in support for the MQTT (MQ Telemetry Transport) messaging protocol and support for the IBM
     Messaging and Queuing middleware products. SAM is designed to be readily extended to
     support other messaging systems and extension modules may be written in C or PHP.
    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="sam.installation"
>安装</A
></H1
><P
>&#13;      The SAM framework and MQTT support can be built and used without any other prerequisites.
      Support for protocols other than MQTT is provided via a set of libraries and some client
      side code referred to as XMS.
    </P
><P
>&#13;      If you only intend to use the built-in MQTT support then you can build and configure SAM as
      an extension or simply refer to "php_sam.php" with a "requires" or "requires_once" clause
      in your PHP script. In this case you need only install the code without building the
      extension using the pear installer:
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>pecl install -B SAM</PRE
></TD
></TR
></TABLE
>
    </P
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.installation.prerequisites"
>Prerequisites</A
></H2
><P
>&#13;       The SAM extension interfaces to the IBM Messaging and Queuing
       middleware products using a set of libraries and some client side code
       referred to as XMS. This package is available as a free download in
       the guise of IBM support pack IA94. There is a description of this
       package and download links in the article <A
HREF="http://www-1.ibm.com/support/docview.wss?uid=swg24007092"
TARGET="_top"
>&#13;       Introducing XMS - The IBM Message Service API</A
>.
      </P
><P
>&#13;       If you intend to use SAM to access the Messaging and Queuing
       infrastructure within WebSphere MQ then you will also need to have
       installed a local MQ queue manager or installed the WebSphere MQ
       clients package. The clients package is freely available as a support
       pack (<A
HREF="http://www-1.ibm.com/support/docview.wss?rs=171&uid=swg24009961&loc=en_US&cs=utf-8&lang=en"
TARGET="_top"
>MQC6</A
>).
      </P
><P
>&#13;       If you are only aiming to experiment with sending messages to and from
       WebSphere Application Server queues using the WebSphere Platform
       Messaging protocol (WPM) then you do not need to install the MQC6
       package.
      </P
><P
>&#13;       After installing these packages you will need to ensure the XMS binary
       and, if you are using it, the MQ client bin directory are included in
       the PATH environment variable so that Apache and PHP can find the
       dependent .DLLs/libraries.
      </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.installation.linux"
>Linux installation steps</A
></H2
><P
>&#13;The sam extension is supplied as a PECL module, which
you should be able to download and install in one step as follows:
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>pecl install sam</PRE
></TD
></TR
></TABLE
>
       (Depending on your php environment, you will probably need to be root
       to do this.)
      </P
><P
>&#13;       Make sure that the module is loaded by PHP, by adding following line
       to <TT
CLASS="filename"
>php.ini</TT
>:
       <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>extension=sam.so</PRE
></TD
></TR
></TABLE
>
      If you intend to use the XMS support to access the IBM Messaging and Queuing family
      you must also enable the SAM XMS extension.
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>extension=sam_xms.so</PRE
></TD
></TR
></TABLE
>
      </P
><P
>&#13;If you cannot use the PEAR installer, you can download the extension and build
it manually:
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>pear download sam          #downloads sam-&#60;version&#62;.tgz
tar -xzf sam-&#60;version&#62;.tgz
cd sam-&#60;version&#62;
phpize
./configure
make
make install               #you may need to be root for this step</PRE
></TD
></TR
></TABLE
>
      </P
><P
>&#13;       To work with the very latest source, you'll need to extract it from
       cvs and build manually as above.
      </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.installation.windows"
>Windows installation steps</A
></H2
><P
>&#13;You will probably need to build the sam extension for Windows as there
are only a limited range of pre-built binaries available from the SAM website.
The extension can be built using the standard Windows extension build procedures.
      </P
><P
>&#13;       You will need the PHP source tree for the version of PHP you wish to
       build the SAM extension against which you can obtain from php.net.
       This should be unpacked into a working directory of your choice.
      </P
><P
>&#13;       You will also need the libraries and headers used by PHP extensions
       available from http://www.php.net/extra/win32build.zip and this
       should be unzipped so that is in your working directory.
      </P
><P
>&#13;       You should have something like:
       <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>c:\php-build\-
              |
              |---php-5.0.5--|---build
              |              |---ext
              |              |--- ...
              |
              |---win32build--|---bin
                              |---include
                              |---lib</PRE
></TD
></TR
></TABLE
>
      </P
><P
>&#13;       You will need a compiler such as the free version of Visual Studio C++
       Express from the Microsoft web site. Also you need the Microsoft
       Windows Platform SDK which again can be downloaded from the Microsoft web site.
      </P
><P
>&#13;Obtain the SAM extension source using pear (pecl download sam) or by using
CVS and copy the files to a new "sam" directory under the "ext" directory
in your PHP source tree.
      </P
><P
>&#13;       To build the extension open a build environment window by going to the
       start menu-&#62;all programs-&#62;microsoft platform SDK for windows-&#62;
       open build environment window-&#62;windows 200 build environment-&#62;
       set windows 2000 build environment (retail)
      </P
><P
>&#13;       This should open a command prompt with all the environment variables
       set up to access the platform SDK etc. You then need to set the
       environment variables for Visual Studio by issuing the command
       "vcvars32.bat" in the window.
      </P
><P
>&#13;       Change directory to your working directory e.g. cd c:\php-build. Then
       make sure the win32build tools are accessible by adding them to the
       PATH environment variable:
       <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>set PATH=..\win32build\bin;%PATH%</PRE
></TD
></TR
></TABLE
>
      </P
><P
>&#13;       Run the buildconf.bat command. This should rebuild the configure.js
       file.
      </P
><P
>&#13;Run the cscript command with the appropriate options. To build just the
SAM extension framework and MQTT support use:
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>cscript /nologo configure.js --with-sam</PRE
></TD
></TR
></TABLE
>
To build the SAM framework and the XMS support use:
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>cscript /nologo configure.js --with-sam --with-sam_xms="c:\program files\ibm\xms"</PRE
></TD
></TR
></TABLE
>
      </P
><P
>&#13;The additional parameter passed for sam_xms is the installation path to the
XMS libraries and runtime that were installed as described under prerequisites
at the top of this page.
      </P
><P
>&#13;       You can specify whatever other cscript parameters you require to
       include or exclude items from the php build or select options.
      </P
><P
>&#13;Assuming all has gone well so far you can now finally run a make for the SAM framework!
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>nmake php_sam.dll</PRE
></TD
></TR
></TABLE
>
Also if you are using the XMS support you must make the sam_xms extensions:
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>nmake php_sam_xms.dll</PRE
></TD
></TR
></TABLE
>
      </P
><P
>&#13;If you have used Visual Studio 2005 to build the DLLs please see below for additional steps that
must be carried out before proceeding further.
      </P
><P
>&#13;The DLLs created (php_sam.dll and optionally php_sam_xms.dll) can now be copied to the
subdirectory appropriate for your PHP set-up. Make sure that the module(s) are loaded by PHP, by adding following line to
      <TT
CLASS="filename"
>php.ini</TT
>
      :
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>extension=php_sam.dll</PRE
></TD
></TR
></TABLE
>
      If you intend to use the XMS support to access the IBM Messgaing and Queuing family
      you must also enable the SAM XMS extension.
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>extension=php_sam_xms.dll</PRE
></TD
></TR
></TABLE
>
      </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.installation.VS2005"
>Additional steps for Visual Studio 2005</A
></H2
><P
>&#13;       If you build the SAM extension with the Microsoft Visual Studio 2005
       compiler and tools you need to perform an additional step in the build
       process to ensure the <TT
CLASS="filename"
>php_sam.dll</TT
> is able to link
       with the C runtime libraries at runtime. This step includes the
       dependancy manifest into the DLL. Switch to the directory where the
       <TT
CLASS="filename"
>php_sam.dll</TT
> has been generated (usually
       Release_TS or Debug_TS below the php source directory) and issue the
       following magic incantation:
       <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>mt.exe -manifest php_sam.dll.manifest -outputresource:php_sam.dll;2</PRE
></TD
></TR
></TABLE
>
If you are using the XMS capabilities you will need to do the same with the
SAM XMS DLL:
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>mt.exe -manifest php_sam_xms.dll.manifest -outputresource:php_sam_xms.dll;2</PRE
></TD
></TR
></TABLE
>
      </P
><P
>&#13;       If you build the SAM extension using the compiler and libaries from
       Microsoft Visual Studio 2005 you will also need to ensure that the
       runtime components are installed on the system on which you intend to
       use SAM. This can be accomplished by installing Visual Studio 2005 or
       by using the freely distributable
       <A
HREF="http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en"
TARGET="_top"
>runtime package</A
>.
      </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.installation.configutaion"
>Protocol support and mapping</A
></H2
><P
>&#13;The SAM framework can be extended to support other messaging protocols and connection mechanisms. To add
support for a new protocol or connection library a support class has to be defined, either as a C extension
or as a PHP script, and a "factory" script must be created. The support class must implement all the
methods of the SAMConnection class though it should not inherit from SAMConnection. The factory script
will be called by the SAM framework to create an instance of the implemented class. The way SAM chooses
which factory to call is based on the protocol specified as the first parameter of the "connect" call.
      </P
><P
>&#13;By default the built-in MQTT support will be used if a connect call specifies a protocol of SAM_MQTT ("mqtt"), for
any other protocol SAM will attempt to use the XMS support extension. To add support for additional
protocols or to modify the default behavior entries may be added to <TT
CLASS="filename"
>php.ini</TT
> in the [sam] section. The
default mapping is equivalent to the following entries:
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>[sam]
sam.factory.mqtt=mqtt
sam.factory.wmq=xms
sam.factory.wmq:client=xms
sam.factory.wmq:bindings=xms
sam.factory.wpm=xms
sam.factory.rtt=xms</PRE
></TD
></TR
></TABLE
>
As can be seen from these examples the entries take the form of "sam.factory.pppp=xxx" where pppp is the protocol
string specified on the connect call and xxx is a factory suffix.  Note: SAM defines constants for these protocol
strings such that SAM_WMQ=wmq, SAM_WPM=wpm, SAM_RTT=rtt, SAM_MQTT=mqtt, etc.
      </P
><P
>&#13;When identifying the support code to use on a connect call SAM looks up the protocol name in the <TT
CLASS="filename"
>php.ini</TT
> entries
and then invokes a factory script named sam_factory_xxx.php.  If no entry is found the support will default to XMS.
      </P
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="sam.usage"
>API Usage</A
></H1
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.connections"
>Connections</A
></H2
><P
>&#13;       In order to perform any messaging and queueing functions a connection
       must be established with a messaging server by creating a SAMConnection
       object and calling its "connect" method, with a set of connection
       properties, to connect the PHP script to the messaging server.  Until
       such time as the SAMConnection object is destroyed the connection
       will be maintained and available for use. All SAMConnection objects
       are destroyed when the PHP script exits.
     </P
><P
>&#13;       A set of default properties may be used in connecting to a messaging
       server but as a minimum the PHP script must specify a protocol to be
       used.
     </P
><P
>&#13;      <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN199954"
></A
><P
><B
>例 1. Creating a connection and connecting to a remote WebSphere MQSeries Messaging Server</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;$conn </font><font color="#007700">= new </font><font color="#0000BB">SAMConnection</font><font color="#007700">();<br />&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">connect</font><font color="#007700">(</font><font color="#0000BB">SAM_WMQ</font><font color="#007700">, array(</font><font color="#0000BB">SAM_HOST </font><font color="#007700">=&gt; </font><font color="#DD0000">'myhost.mycompany.com'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">SAM_PORT </font><font color="#007700">=&gt; </font><font color="#0000BB">1506</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">SAM_BROKER </font><font color="#007700">=&gt; </font><font color="#DD0000">'mybroker'</font><font color="#007700">));<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="AEN199958"
></A
><P
><B
>例 2. Creating a connection and connecting to a remote WebSphere Application Server</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;$conn </font><font color="#007700">= new </font><font color="#0000BB">SAMConnection</font><font color="#007700">();<br />&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">connect</font><font color="#007700">(</font><font color="#0000BB">SAM_WPM</font><font color="#007700">, array(</font><font color="#0000BB">SAM_ENDPOINTS </font><font color="#007700">=&gt; </font><font color="#DD0000">'localhost:7278:BootstrapBasicMessaging'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">SAM_BUS </font><font color="#007700">=&gt; </font><font color="#DD0000">'Bus1'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">SAM_TARGETCHAIN </font><font color="#007700">=&gt; </font><font color="#DD0000">'InboundBasicMessaging'</font><font color="#007700">));<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="AEN199962"
></A
><P
><B
>例 3. Creating a connection and connecting to an MQTT server</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;$conn </font><font color="#007700">= new </font><font color="#0000BB">SAMConnection</font><font color="#007700">();<br />&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">connect</font><font color="#007700">(</font><font color="#0000BB">SAM_MQTT</font><font color="#007700">, array(</font><font color="#0000BB">SAM_HOST </font><font color="#007700">=&gt; </font><font color="#DD0000">'myhost.mycompany.com'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">SAM_PORT </font><font color="#007700">=&gt; </font><font color="#0000BB">1883</font><font color="#007700">));<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
     </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.messages"
>Messages</A
></H2
><P
>&#13;      Messages sent to and received from queues are represented by the
      SAMMessage object. The SAMMessage object encapsulates the body of
      the message (if one exists) and the header properties associated with
      the message. A SAMMessage object is either supplied as a parameter to
      a messaging operation or returned as a result.
     </P
><P
>&#13;      <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN199969"
></A
><P
><B
>例 4. Creating a message with a simple text body</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">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
     </P
><P
>&#13;      Messages may have header properties associated with them that provide
      control over the transport of the message or further information to the
      receiving application. By default message properties are delivered to
      the underlying messaging system as strings and in this case they may be
      set with the following simple syntax:
     </P
><P
>&#13;      <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN199974"
></A
><P
><B
>例 5. Setting a text format property using the default syntax</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myPropertyName </font><font color="#007700">= </font><font color="#DD0000">'textData'</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
     </P
><P
>&#13;      If it is desired to pass type information an alternative syntax may be
      used where the value and the type hint are passed in an associative
      array:
     </P
><P
>&#13;      <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN199979"
></A
><P
><B
>例 6. Setting a property using a type hint</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myPropertyName </font><font color="#007700">= array(</font><font color="#0000BB">3.14159</font><font color="#007700">, </font><font color="#0000BB">SAM_FLOAT</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
     </P
><P
>&#13;      Properties may also be extracted from the header of a message.
     </P
><P
>&#13;      <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN199984"
></A
><P
><B
>例 7. Retrieving a property from a message header</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;$myProperty </font><font color="#007700">= </font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myPropertyName</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
     </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.operations"
>Messaging operations</A
></H2
><P
>&#13;      All messaging operations are performed through calls to methods on the
      connection object.
      To add a message to a queue the "send" method is used, to obtain a
      message from a queue the "receive" method is used. Other methods
      provide publish and subscribe functionality and control of transaction
      boundaries.
     </P
><P
>&#13;      <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN199991"
></A
><P
><B
>例 8. Adding a message to a queue and receiving 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;</font><font color="#FF8000">// The Send failed!<br />&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;</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="section"
><H2
CLASS="section"
><A
NAME="sam.pubsub"
>Publish/Subscribe and suscriptions to topics</A
></H2
><P
>&#13;      SAM allows messages to be sent either to queues or, for WebSphere MQ
      and WPM, to publish/subscribe topics.
      A topic desintation is specified to SAM in the usual way, i.e. in the
      form 'topic://fred', rather than the form 'queue://AQUEUE' used for
      point to point operation. To use publish/subscribe it is simply
      necessary to specify the correct broker name on the SAMConnect
      "connect" call and the desired topic in the destination argument to
      the SAMConnect "send" and "receive" calls. The PHP interface is
      otherwise identical to the point to point model.
     </P
><P
>&#13;      By default, SAM creates non-durable subscriptions when using
      publish/subscribe. This means that if a client application is
      inactive when messages are published to a topic, then it will not
      receive them when it subsequently restarted. SAM does also allow
      durable subscriptions to be made to topics when using WPM or WebSphere
      MQ publish/subscribe. The purpose of these subscriptions is to allow
      data to be received by a client application even if that client was not
      active at the time the data was published.
     </P
><P
>&#13;      Durable subscriptions are specified by using the SAMConnect "subscribe"
      call. This method takes the destination topic as an input parameter and
      returns a subscription identifier that may be used on subsequent
      "receive" calls. When the subscription is no longer required the
      SAMConnection "unsubscribe" method should be used to delete the
      subscription.
     </P
><P
>&#13;      <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN200000"
></A
><P
><B
>例 9. Creating a durable subscription to a topic</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$subName </font><font color="#007700">= </font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">subscribe</font><font color="#007700">(</font><font color="#DD0000">'topic://A'</font><font color="#007700">);<br /><br />if (!</font><font color="#0000BB">$subName</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Subscribe failed"</font><font color="#007700">;<br />} else {<br />&nbsp;&nbsp;&nbsp;</font><font color="#FF8000"># Subscribe was OK<br />&nbsp;&nbsp;&nbsp;// ...<br /></font><font color="#007700">}<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="AEN200004"
></A
><P
><B
>例 10. Subscribing to a topic using a WebSphere Platform Messaging (WPM) server</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$conn </font><font color="#007700">= new </font><font color="#0000BB">SAMConnection</font><font color="#007700">();<br /></font><font color="#FF8000">// Note: For pub/sub on WPM, when connecting the name of a messaging engine<br />//&nbsp;&nbsp;&nbsp;to hold the durable subscription (SAM_WPM_DUR_SUB_HOME) must be specified.<br /></font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">connect</font><font color="#007700">(</font><font color="#0000BB">SAM_WMQ</font><font color="#007700">, array(</font><font color="#0000BB">SAM_ENDPOINTS </font><font color="#007700">=&gt; </font><font color="#DD0000">'localhost:7278:BootstrapBasicMessaging'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">SAM_BUS </font><font color="#007700">=&gt; </font><font color="#DD0000">'Bus1'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">SAM_TARGETCHAIN </font><font color="#007700">=&gt; </font><font color="#DD0000">'InboundBasicMessaging'<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">SAM_WPM_DUR_SUB_HOME </font><font color="#007700">=&gt; </font><font color="#DD0000">'MyMachineNode01.server1-Bus1'</font><font color="#007700">));<br /><br /></font><font color="#0000BB">$subName </font><font color="#007700">= </font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">subscribe</font><font color="#007700">(</font><font color="#DD0000">'topic://A'</font><font color="#007700">);<br /><br />if (!</font><font color="#0000BB">$subName</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Subscribe failed"</font><font color="#007700">;<br />} else {<br />&nbsp;&nbsp;&nbsp;</font><font color="#FF8000"># Subscribe was OK<br />&nbsp;&nbsp;&nbsp;// ...<br /></font><font color="#007700">}<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="AEN200008"
></A
><P
><B
>例 11. Receiving published data using a durable subscription</B
></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="#0000BB">$subName</font><font color="#007700">);<br />if (</font><font color="#0000BB">$msg</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Received a message OK"</font><font color="#007700">;<br />} else {<br />&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"The receive failed"</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="AEN200012"
></A
><P
><B
>例 12. Deleting a durable subscription to a topic</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br /></font><font color="#007700">if (!</font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">unsubscribe</font><font color="#007700">(</font><font color="#0000BB">$subName</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Unsubscribe failed"</font><font color="#007700">;<br />}<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
     </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.errors"
>Error handling</A
></H2
><P
>&#13;      All SAMConnection methods that provide access to messaging operations
      return <TT
CLASS="constant"
><B
>FALSE</B
></TT
> if an error occurred in processing the request.
      In addition the SAMConnection object has two properties, "errno"
      and "error", that provide respectively the error number and
      text description of the last error to occur on the connection.
     </P
><P
>&#13;      <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN200020"
></A
><P
><B
>例 13. Handling an error from a method that returns no result</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;</font><font color="#007700">if (!</font><font color="#0000BB">$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">commit</font><font color="#007700">()) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// The commit failed!<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">echo </font><font color="#DD0000">"Commit 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 />&nbsp;&nbsp;&nbsp;}<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="AEN200024"
></A
><P
><B
>例 14. Handling an error from a method that returns a result</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$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;</font><font color="#FF8000">// The Send failed!<br />&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;...<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
     </P
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="sam.classes"
>预定义类</A
></H1
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.class.Connection"
><B
CLASS="classname"
>SAMConnection</B
></A
></H2
><P
>&#13;      Object representing a connection to a Messaging Server
     </P
><DIV
CLASS="section"
><H3
CLASS="section"
><A
NAME="sam.class.Connection.constructor"
>构造函数</A
></H3
><P
></P
><UL
><LI
><P
>&#13;         <A
HREF="function.samconnection-constructor.html"
>new SAMConnection</A
> - construct a new connection object to allow connection to a messaging infrastructure.
        </P
></LI
></UL
></DIV
><DIV
CLASS="section"
><H3
CLASS="section"
><A
NAME="sam.class.Connection.methods"
>方法</A
></H3
><P
></P
><UL
><LI
><P
>&#13;         <A
HREF="function.samconnection-commit.html"
>commit</A
>
         - a method that commits (successfully completes) an in-flight unit
         of work.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-connect.html"
>connect</A
>
         - a method that connects a PHP script to a messaging server.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-disconnect.html"
>disconnect</A
>
         - a method that disconnects a PHP script from a messaging server.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-isconnected.html"
>isConnected</A
>
         - a method that checks whether a PHP script is connected to a
          messaging server.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-peek.html"
>peek</A
>
         - a method that receives a message from a queue without removing it
          from the queue.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-peekall.html"
>peekAll</A
>
         - a method that receives one or messages from a queue without
         removing them from the queue.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-receive.html"
>receive</A
>
         - a method that receives a message from a queue or subscription.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-remove.html"
>remove</A
>
         - a method that removes a message from a queue.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-rollback.html"
>rollback</A
>
         - a method that cancels (rolls back) an in-flight unit of work.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-send.html"
>send</A
>
         - a method that sends a message to a queue or posts to a topic
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-setdebug.html"
>setDebug</A
>
         - a method that switches additional debugging output on or off
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-subscribe.html"
>subscribe</A
>
         - a method that creates a subscription to one or more topics
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-unsubscribe.html"
>unsubscribe</A
>
         - a method that destroys a subscription to one or more topics
        </P
></LI
></UL
></DIV
><DIV
CLASS="section"
><H3
CLASS="section"
><A
NAME="sam.class.Connection.properties"
>属性</A
></H3
><P
></P
><UL
><LI
><P
>&#13;         <A
HREF="function.samconnection-errno.html"
>errno</A
> - the
         numeric error code for the last encountered error on this
         connection. This property is set to 0 if the last operation was
         successful.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.samconnection-error.html"
>error</A
> - the
         text description for the last encountered error on this connection
        </P
></LI
></UL
></DIV
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="sam.class.Message"
><B
CLASS="classname"
>SAMMessage</B
></A
></H2
><P
>&#13;      Object representing a message to be sent or received
     </P
><DIV
CLASS="section"
><H3
CLASS="section"
><A
NAME="sam.class.Message.constructor"
>构造函数</A
></H3
><P
></P
><UL
><LI
><P
>&#13;         <A
HREF="function.sammessage-constructor.html"
>new SAMMessage</A
> - construct a
         new message.
        </P
></LI
></UL
></DIV
><DIV
CLASS="section"
><H3
CLASS="section"
><A
NAME="sam.class.Message.properties"
>属性</A
></H3
><P
></P
><UL
><LI
><P
>&#13;         <A
HREF="function.sammessage-body.html"
>body</A
> - the body of
         the message.
        </P
></LI
><LI
><P
>&#13;         <A
HREF="function.sammessage-header.html"
>header</A
> - the
         header properties of the message.
        </P
></LI
></UL
></DIV
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="mq.constants"
>预定义常量</A
></H1
><P
>以下常量由本扩展模块定义,因此只有在本扩展模块被编译到
PHP 中,或者在运行时被动态加载后才有效。</P
><P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><TT
CLASS="constant"
><B
>SAM_AUTO</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Automatic behaviour
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_BOOLEAN</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Type specifier used when setting properties on SAM_Message objects.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_BUS</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect attribute used to set the name of the enterprise service bus to
     connect to.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_BYTE</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Type specifier used when setting properties on SAM_Message objects.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_BYTES</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Message body type descriptor.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_CORRELID</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Attribute used on receive, send and remove requests to identify specific
     messages.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_DELIVERYMODE</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Message header property.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_DOUBLE</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Type specifier used when setting properties on SAM_Message objects.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_ENDPOINTS</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect attribute used to define the possible endpoints to connect to.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_FLOAT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Type specifier used when setting properties on SAM_Message objects.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_HOST</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect attribute used to set the hostname of the required messaging
     server.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_INT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Type specifier used when setting properties on SAM_Message objects.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_LONG</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Type specifier used when setting properties on SAM_Message objects.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_MANUAL</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Manual (script controlled) behaviour
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_MESSAGEID</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Attribute used on receive and remove requests to identify specific
     messages.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_MQTT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect protocol definition for selecting the MQTT (MQ Telemetry Transport) protocol.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_MQTT_CLEANSTART</B
></TT
>
     (<A
HREF="language.types.boolean.html"
><B
CLASS="type"
>bool</B
></A
>)</DT
><DD
><P
>&#13;     Optional connect option to indicate to an MQTT server that all previous connection data
     for this client should be removed and that subscriptions should be deleted when the client
     disconnects explicitly or unexpectedly.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_NON_PERSISTENT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect attribute value used to request messages are not made persistent
     on the messaging server.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_PASSWORD</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect attribute used to define the password to be used for the user
     account being used to connect to a messaging server that requires
     authorisation for connections.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_PERSISTENT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect attribute value used to request messages are made persistent
     on the messaging server to protect against loss of messages in the
     event of failure.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_PORT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect attribute used to set the port number on which to communicate
     with the messaging server.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_PRIORITY</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Option name used on send requests to specify a delivery priority value.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_REPLY_TO</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Message propery used to specify the queue identity on to which the 
     script expects response or reply messages to be posted.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_RTT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect protocol definition for selecting the IBM Realtime Transport
     protocol for communication with a business integration messaging server.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_STRING</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Type specifier used when setting properties on SAM_Message objects.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_TARGETCHAIN</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connection attribute used to set the required target chain identifier.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_TEXT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Message body type descriptor.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_TIMETOLIVE</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Message send option name used to specify the length of time a message
     should be retained in milliseconds.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_TRANSACTIONS</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connection attribute used to set required transactional behaviour. May
     be set to SAM_AUTO (default) or SAM_MANUAL.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_USERID</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect attribute used to define the account to being used to
     connect to a messaging server that requires authorisation for connections.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_WAIT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Receive property used to specify the wait timeout to be used when
     receiving a message from a queue or subscription.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_WMQ</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect protocol definition for selecting the IBM WebSphere MQSeries
     protocol for communication with the desired messaging server.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_WMQ_BINDINGS</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect protocol definition for selecting the IBM WebSphere MQSeries
     protocol for communication with a local messaging server.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_WMQ_CLIENT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect protocol definition for selecting the IBM WebSphere MQSeries
     protocol for communication with a remote messaging server.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_WMQ_TARGET_CLIENT</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Option name used on send requests to specify the target client mode. 
     This can either be default to 'jms' or 'mq'. The default is 'jms' which
     means an RFH2 header is sent with the message whereas the 'mq' setting
     means no RFH2 is included.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>SAM_WPM</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Connect protocol definition for selecting the IBM WebSphere Platform
     Messaging protocol for communication with a WebSphere Application Server
     messaging server.
    </P
></DD
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>目录</B
></DT
><DT
><A
HREF="function.samconnection-commit.html"
>SAMConnection-&#62;commit()</A
>&nbsp;--&nbsp;
   Commits (completes) the current unit of work.
  </DT
><DT
><A
HREF="function.samconnection-connect.html"
>SAMConnection-&#62;connect()</A
>&nbsp;--&nbsp;
   Establishes a connection to a Messaging Server
  </DT
><DT
><A
HREF="function.samconnection-constructor.html"
>SAMConnection-&#62;__construct()</A
>&nbsp;--&nbsp;
   Creates a new connection to a Messaging Server
  </DT
><DT
><A
HREF="function.samconnection-disconnect.html"
>SAMConnection-&#62;disconnect()</A
>&nbsp;--&nbsp;
   Disconnects from a Messaging Server
  </DT
><DT
><A
HREF="function.samconnection-errno.html"
>SAMConnection-&#62;errno</A
>&nbsp;--&nbsp;Contains the unique numeric error code of the last executed SAM operation.</DT
><DT
><A
HREF="function.samconnection-error.html"
>SAMConnection-&#62;error</A
>&nbsp;--&nbsp;Contains the text description of the last failed SAM operation.</DT
><DT
><A
HREF="function.samconnection-isconnected.html"
>SAMConnection-&#62;isConnected()</A
>&nbsp;--&nbsp;
   Queries whether a connection is established to a Messaging Server
  </DT
><DT
><A
HREF="function.samconnection-peek.html"
>SAMConnection-&#62;peek()</A
>&nbsp;--&nbsp;
   Read a message from a queue without removing it from the queue.
  </DT
><DT
><A
HREF="function.samconnection-peekall.html"
>SAMConnection-&#62;peekAll()</A
>&nbsp;--&nbsp;
   Read one or more messages from a queue without removing it from the queue.
  </DT
><DT
><A
HREF="function.samconnection-receive.html"
>SAMConnection-&#62;receive()</A
>&nbsp;--&nbsp;
   Receive a message from a queue or subscription.
  </DT
><DT
><A
HREF="function.samconnection-remove.html"
>SAMConnection-&#62;remove()</A
>&nbsp;--&nbsp;
   Remove a message from a queue.
  </DT
><DT
><A
HREF="function.samconnection-rollback.html"
>SAMConnection-&#62;rollback()</A
>&nbsp;--&nbsp;
   Cancels (rolls back) an in-flight unit of work.
  </DT
><DT
><A
HREF="function.samconnection-send.html"
>SAMConnection-&#62;send()</A
>&nbsp;--&nbsp;
   Send a message to a queue or publish an item to a topic.
  </DT
><DT
><A
HREF="function.samconnection-setdebug.html"
>SAMConnection::setDebug()</A
>&nbsp;--&nbsp;
   Turn on or off additional debugging output.
  </DT
><DT
><A
HREF="function.samconnection-subscribe.html"
>SAMConnection-&#62;subscribe()</A
>&nbsp;--&nbsp;
   Create a subscription to a specified topic.
  </DT
><DT
><A
HREF="function.samconnection-unsubscribe.html"
>SAMConnection-&#62;unsubscribe()</A
>&nbsp;--&nbsp;
   Cancel a subscription to a specified topic.
  </DT
><DT
><A
HREF="function.sammessage-body.html"
>SAMMessage-&#62;body</A
>&nbsp;--&nbsp;
   The body of the message.
  </DT
><DT
><A
HREF="function.sammessage-constructor.html"
>SAMMessage-&#62;__construct()</A
>&nbsp;--&nbsp;
   Creates a new Message object
  </DT
><DT
><A
HREF="function.sammessage-header.html"
>SAMMessage-&#62;header</A
>&nbsp;--&nbsp;
   The header properties of the message.
  </DT
></DL
></DIV
></DIV
></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.runkit-superglobals.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-commit.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>runkit_superglobals</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SAMConnection-&#62;commit()</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>