cvs: phpdoc /en/reference/sam book.xml constants.xml examples.xml reference.xml setup.xml
| From: | Philip Olson | Date: | Fri, 21 Dec 2007 20:27:30 +0000 |
| Subject: | cvs: phpdoc /en/reference/sam book.xml constants.xml examples.xml reference.xml setup.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-693@lists.php.net to get a copy of this message | ||
philip Fri Dec 21 20:27:30 2007 UTC
Modified files:
/phpdoc/en/reference/sam book.xml setup.xml examples.xml
reference.xml constants.xml
Log:
MFB: Upgrade to the new-reference-structure
- Split reference.xml into book.xml, setup.xml, and examples.xml
- Moved from reference.xml to book.xml:
- The intro text (partintro), and link to various pages
- Moved from reference.xml to setup.xml:
- The rest: requirements, installation, configuration, and resources
- Changed the constants section to be an <appendix>
- Changed the intro ID from <extname>.intro to intro.<extname>
- TODO: OO structure change (extra info remains in reference.xml for now)
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/sam/book.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/en/reference/sam/book.xml diff -u /dev/null phpdoc/en/reference/sam/book.xml:1.2 --- /dev/null Fri Dec 21 20:27:30 2007 +++ phpdoc/en/reference/sam/book.xml Fri Dec 21 20:27:30 2007 @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.2 $ --> +<!-- Purpose: remote.other --> +<!-- Membership: pecl --> + +<book xml:id="book.sam" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + <title>Simple Asynchronous Messaging</title> + + <!-- {{{ preface --> + <preface xml:id="intro.sam"> + &reftitle.intro; + <para> + 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. + </para> + <para> + 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. + </para> + </preface> + <!-- }}} --> + + &reference.sam.setup; + &reference.sam.constants; + &reference.sam.examples; + &reference.sam.reference; + +</book> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> + http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/sam/setup.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/en/reference/sam/setup.xml diff -u /dev/null phpdoc/en/reference/sam/setup.xml:1.2 --- /dev/null Fri Dec 21 20:27:30 2007 +++ phpdoc/en/reference/sam/setup.xml Fri Dec 21 20:27:30 2007 @@ -0,0 +1,351 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.2 $ --> + +<chapter xml:id="sam.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + &reftitle.setup; + + <!-- {{{ Requirements --> + <section xml:id="sam.requirements"> + &reftitle.required; + <para> + 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 <link xlink:href="&url.ibm.ia94;"> + Introducing XMS - The IBM Message Service API</link>. + </para> + <para> + 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 (<link xlink:href="&url.ibm.mqc6;">MQC6</link>). + </para> + <para> + 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. + </para> + <para> + 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. + </para> + </section> + <!-- }}} --> + + <!-- {{{ Installation --> + <section xml:id="sam.installation"> + &reftitle.install; + <para> + 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. + </para> + <para> + 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: + <screen> +<![CDATA[ +pecl install -B SAM +]]> + </screen> + </para> + + <!-- {{{ Linux --> + <section xml:id='sam.installation.linux'> + <title>Linux installation steps</title> + <para> + The sam extension is supplied as a PECL module, which + you should be able to download and install in one step as follows: + <screen> +<![CDATA[ +pecl install sam +]]> + </screen> + (Depending on your php environment, you will probably need to be root + to do this.) + </para> + <para> + Make sure that the module is loaded by PHP, by adding following line + to &php.ini;: + <screen> +<![CDATA[ +extension=sam.so +]]> + </screen> + If you intend to use the XMS support to access the IBM Messaging and Queuing family + you must also enable the SAM XMS extension. + <screen> +<![CDATA[ +extension=sam_xms.so +]]> + </screen> + </para> + <para> + If you cannot use the PEAR installer, you can download the extension + and build it manually: + <screen> +<![CDATA[ +pear download sam #downloads sam-<version>.tgz +tar -xzf sam-<version>.tgz +cd sam-<version> +phpize +./configure +make +make install #you may need to be root for this step +]]> + </screen> + </para> + <para> + To work with the very latest source, you'll need to extract it from + cvs and build manually as above. + </para> + </section> + <!-- }}} --> + <!-- {{{ Windows --> + <section xml:id='sam.installation.windows'> + <title>Windows installation steps</title> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + You should have something like: + <screen> +<![CDATA[ +c:\php-build\- + | + |---php-5.0.5--|---build + | |---ext + | |--- ... + | + |---win32build--|---bin + |---include + |---lib +]]> + </screen> + </para> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + To build the extension open a build environment window by going to the + start menu->all programs->microsoft platform SDK for windows-> + open build environment window->windows 200 build environment-> + set windows 2000 build environment (retail) + </para> + <para> + 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. + </para> + <para> + 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: + <screen> +<![CDATA[ +set PATH=..\win32build\bin;%PATH% +]]> + </screen> + </para> + <para> + Run the buildconf.bat command. This should rebuild the configure.js + file. + </para> + <para> + Run the cscript command with the appropriate options. To build just the + SAM extension framework and MQTT support use: + <screen> +<![CDATA[ +cscript /nologo configure.js --with-sam +]]> + </screen> + To build the SAM framework and the XMS support use: + <screen> +<![CDATA[ +cscript /nologo configure.js --with-sam --with-sam_xms="c:\program files\ibm\xms" +]]> + </screen> + </para> + <para> + 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. + </para> + <para> + You can specify whatever other cscript parameters you require to + include or exclude items from the php build or select options. + </para> + <para> + Assuming all has gone well so far you can now finally run a make for the SAM framework! + <screen> +<![CDATA[ +nmake php_sam.dll +]]> + </screen> + Also if you are using the XMS support you must make the sam_xms extensions: + <screen> +<![CDATA[ +nmake php_sam_xms.dll +]]> + </screen> + </para> + <para> + 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. + </para> + <para> + 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 &php.ini;: + <screen> +<![CDATA[ +extension=php_sam.dll +]]> + </screen> + If you intend to use the XMS support to access the IBM Messgaing and Queuing family + you must also enable the SAM XMS extension. + <screen> +<![CDATA[ +extension=php_sam_xms.dll +]]> + </screen> + </para> + </section> + <!-- }}} --> + <!-- {{{ VS2005 --> + <section xml:id='sam.installation.VS2005'> + <title>Additional steps for Visual Studio 2005</title> + <para> + 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 <filename>php_sam.dll</filename> 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 + <filename>php_sam.dll</filename> has been generated (usually + Release_TS or Debug_TS below the php source directory) and issue the + following magic incantation: + <screen> +<![CDATA[ +mt.exe -manifest php_sam.dll.manifest -outputresource:php_sam.dll;2 +]]> + </screen> + If you are using the XMS capabilities you will need to do the same with the + SAM XMS DLL: + <screen> +<![CDATA[ +mt.exe -manifest php_sam_xms.dll.manifest -outputresource:php_sam_xms.dll;2 +]]> + </screen> + </para> + <para> + 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 + <link xlink:href="&url.ms.crt;">runtime package</link>. + </para> + </section> + <!-- }}} --> + </section> + <!-- }}} --> + + <!-- {{{ Configuration --> + <section xml:id="sam.configuration"> + &reftitle.runtime; + <section xml:id="sam.configuration.mapping"> + <title>Protocol support and mapping</title> + <para> + 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. + </para> + <para> + 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 &php.ini; in the [sam] section. The + default mapping is equivalent to the following entries: + <screen> +<![CDATA[ +[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 +]]> + </screen> + 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. + </para> + <para> + When identifying the support code to use on a connect call SAM looks up the protocol name in the &php.ini; entries + and then invokes a factory script named sam_factory_xxx.php. If no entry is found the support will default to XMS. + </para> + </section> + </section> + <!-- }}} --> + + <!-- {{{ Resources --> + <section xml:id="sam.resources"> + &reftitle.resources; + &no.resource; + </section> + <!-- }}} --> + +</chapter> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> + http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/sam/examples.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/en/reference/sam/examples.xml diff -u /dev/null phpdoc/en/reference/sam/examples.xml:1.2 --- /dev/null Fri Dec 21 20:27:30 2007 +++ phpdoc/en/reference/sam/examples.xml Fri Dec 21 20:27:30 2007 @@ -0,0 +1,357 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.2 $ --> + +<chapter xml:id="sam.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + &reftitle.examples; + <section xml:id='sam.connections'> + <title>Connections</title> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + <example> + <title>Creating a connection and connecting to a remote WebSphere MQSeries Messaging Server</title> + <programlisting role='php'> +<![CDATA[ +<?php +$conn = new SAMConnection(); +$conn->connect(SAM_WMQ, array(SAM_HOST => 'myhost.mycompany.com', + SAM_PORT => 1506, + SAM_BROKER => 'mybroker')); +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Creating a connection and connecting to a remote WebSphere Application Server</title> + <programlisting role='php'> +<![CDATA[ +<?php +$conn = new SAMConnection(); +$conn->connect(SAM_WPM, array(SAM_ENDPOINTS => 'localhost:7278:BootstrapBasicMessaging', + SAM_BUS => 'Bus1', + SAM_TARGETCHAIN => 'InboundBasicMessaging')); +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Creating a connection and connecting to an MQTT server</title> + <programlisting role='php'> +<![CDATA[ +<?php +$conn = new SAMConnection(); +$conn->connect(SAM_MQTT, array(SAM_HOST => 'myhost.mycompany.com', + SAM_PORT => 1883)); +?> +]]> + </programlisting> + </example> + </para> + </section> <!-- xml:id=sam.connections --> + + <section xml:id='sam.messages'> + <title>Messages</title> + <para> + 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. + </para> + <para> + <example> + <title>Creating a message with a simple text body</title> + <programlisting role="php"> +<![CDATA[ +<?php +$msg = new SAMMessage('This is a simple text message'); +?> +]]> + </programlisting> + </example> + </para> + <para> + 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: + </para> + <para> + <example> + <title>Setting a text format property using the default syntax</title> + <programlisting role="php"> +<![CDATA[ +<?php +$msg->header->myPropertyName = 'textData'; +?> +]]> + </programlisting> + </example> + </para> + <para> + 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: + </para> + <para> + <example> + <title>Setting a property using a type hint</title> + <programlisting role="php"> +<![CDATA[ +<?php +$msg->header->myPropertyName = array(3.14159, SAM_FLOAT); +?> +]]> + </programlisting> + </example> + </para> + <para> + Properties may also be extracted from the header of a message. + </para> + <para> + <example> + <title>Retrieving a property from a message header</title> + <programlisting role="php"> +<![CDATA[ +<?php +$myProperty = $msg->header->myPropertyName; +?> +]]> + </programlisting> + </example> + </para> + </section> <!-- xml:id=sam.messages --> + + <section xml:id='sam.operations'> + <title>Messaging operations</title> + <para> + 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. + </para> + <para> + <example> + <title>Adding a message to a queue and receiving a response</title> + <programlisting role="php"> +<![CDATA[ +<?php +$msg = new SAMMessage('This is a simple text message'); +$msg->header->SAM_REPLY_TO = 'queue://receive/test'; +$correlid = $conn->send('queue://send/test', $msg); + +if (!$correlid) { + // The Send failed! + echo "Send failed ($conn->errno) $conn->error"; +} else { + $resp = $conn->receive('queue://receive/test', array(SAM_CORRELID => $correlid)); +} +?> +]]> + </programlisting> + </example> + </para> + </section> <!-- xml:id=sam.operations --> + + <section xml:id='sam.pubsub'> + <title>Publish/Subscribe and suscriptions to topics</title> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + <example> + <title>Creating a durable subscription to a topic</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$subName = $conn->subscribe('topic://A'); + +if (!$subName) { + echo "Subscribe failed"; +} else { + # Subscribe was OK + // ... +} +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Subscribing to a topic using a WebSphere Platform Messaging (WPM) server</title> + <programlisting role="php"> +<![CDATA[ +<?php +$conn = new SAMConnection(); +// Note: For pub/sub on WPM, when connecting the name of a messaging engine +// to hold the durable subscription (SAM_WPM_DUR_SUB_HOME) must be specified. +$conn->connect(SAM_WMQ, array(SAM_ENDPOINTS => 'localhost:7278:BootstrapBasicMessaging', + SAM_BUS => 'Bus1', + SAM_TARGETCHAIN => 'InboundBasicMessaging' + SAM_WPM_DUR_SUB_HOME => 'MyMachineNode01.server1-Bus1')); + +$subName = $conn->subscribe('topic://A'); + +if (!$subName) { + echo "Subscribe failed"; +} else { + # Subscribe was OK + // ... +} +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Receiving published data using a durable subscription</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$msg = $conn->receive($subName); +if ($msg) { + echo "Received a message OK"; +} else { + echo "The receive failed"; +} + +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Deleting a durable subscription to a topic</title> + <programlisting role="php"> +<![CDATA[ +<?php + +if (!$conn->unsubscribe($subName)) { + echo "Unsubscribe failed"; +} + +?> +]]> + </programlisting> + </example> + </para> + </section> <!-- xml:id=sam.pubsub --> + + <section xml:id='sam.errors'> + <title>Error handling</title> + <para> + All SAMConnection methods that provide access to messaging operations + return &false; 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. + </para> + <para> + <example> + <title>Handling an error from a method that returns no result</title> + <programlisting role="php"> +<![CDATA[ +<?php +if (!$conn->commit()) { + // The commit failed! + echo "Commit failed ($conn->errno) $conn->error"; +} +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Handling an error from a method that returns a result</title> + <programlisting role="php"> +<![CDATA[ +<?php +$correlid = $conn->send('queue://send/test', $msg); + +if (!$correlid) { + // The Send failed! + echo "Send failed ($conn->errno) $conn->error"; +} else { + ... +} +?> +]]> + </programlisting> + </example> + </para> + </section> <!-- xml:id=sam.errors --> + +</chapter> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> + http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/sam/reference.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/sam/reference.xml diff -u phpdoc/en/reference/sam/reference.xml:1.10 phpdoc/en/reference/sam/reference.xml:1.11 --- phpdoc/en/reference/sam/reference.xml:1.10 Mon Dec 10 17:06:08 2007 +++ phpdoc/en/reference/sam/reference.xml Fri Dec 21 20:27:30 2007 @@ -1,660 +1,11 @@ <?xml version='1.0' encoding='iso-8859-1'?> -<!-- $Revision: 1.10 $ --> -<!-- Purpose: remote.other --> -<!-- Membership: pecl --> +<!-- $Revision: 1.11 $ --> <reference xml:id="ref.sam" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> - <title>SAM - Simple Asynchronous Messaging</title> - <titleabbrev>SAM</titleabbrev> + <title>SAM &Functions;</title> <partintro> - <section xml:id="sam.intro"> - &reftitle.intro; - <para> - 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. - </para> - <para> - 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. - </para> - </section> <!-- xml:id=sam.intro --> - - <section xml:id='sam.installation'> - &reftitle.install; - <para> - 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. - </para> - <para> - 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: - <screen> - <![CDATA[ - pecl install -B SAM -]]> - </screen> - </para> - <section xml:id='sam.installation.prerequisites'> - <title>Prerequisites</title> - <para> - 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 <link xlink:href="&url.ibm.ia94;"> - Introducing XMS - The IBM Message Service API</link>. - </para> - <para> - 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 (<link xlink:href="&url.ibm.mqc6;">MQC6</link>). - </para> - <para> - 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. - </para> - <para> - 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. - </para> - </section> - <section xml:id='sam.installation.linux'> - <title>Linux installation steps</title> - <para> -The sam extension is supplied as a PECL module, which -you should be able to download and install in one step as follows: - <screen> - <![CDATA[ -pecl install sam -]]> - </screen> - (Depending on your php environment, you will probably need to be root - to do this.) - </para> - <para> - Make sure that the module is loaded by PHP, by adding following line - to &php.ini;: - <screen> -<![CDATA[ -extension=sam.so -]]> - </screen> - If you intend to use the XMS support to access the IBM Messaging and Queuing family - you must also enable the SAM XMS extension. - <screen> - <![CDATA[ -extension=sam_xms.so -]]> - </screen> - </para> - <para> -If you cannot use the PEAR installer, you can download the extension and build -it manually: - <screen> -<![CDATA[ -pear download sam #downloads sam-<version>.tgz -tar -xzf sam-<version>.tgz -cd sam-<version> -phpize -./configure -make -make install #you may need to be root for this step -]]> - </screen> - </para> - <para> - To work with the very latest source, you'll need to extract it from - cvs and build manually as above. - </para> - </section> - <section xml:id='sam.installation.windows'> - <title>Windows installation steps</title> - <para> -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. - </para> - <para> - 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. - </para> - <para> - 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. - </para> - <para> - You should have something like: - <screen> -<![CDATA[ -c:\php-build\- - | - |---php-5.0.5--|---build - | |---ext - | |--- ... - | - |---win32build--|---bin - |---include - |---lib -]]> - </screen> - </para> - <para> - 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. - </para> - <para> -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. - </para> - <para> - To build the extension open a build environment window by going to the - start menu->all programs->microsoft platform SDK for windows-> - open build environment window->windows 200 build environment-> - set windows 2000 build environment (retail) - </para> - <para> - 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. - </para> - <para> - 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: - <screen> -<![CDATA[ -set PATH=..\win32build\bin;%PATH% -]]> - </screen> - </para> - <para> - Run the buildconf.bat command. This should rebuild the configure.js - file. - </para> - <para> -Run the cscript command with the appropriate options. To build just the -SAM extension framework and MQTT support use: - <screen> - <![CDATA[ -cscript /nologo configure.js --with-sam -]]> - </screen> -To build the SAM framework and the XMS support use: - <screen> - <![CDATA[ -cscript /nologo configure.js --with-sam --with-sam_xms="c:\program files\ibm\xms" -]]> - </screen> - </para> - <para> -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. - </para> - <para> - You can specify whatever other cscript parameters you require to - include or exclude items from the php build or select options. - </para> - <para> -Assuming all has gone well so far you can now finally run a make for the SAM framework! - <screen> - <![CDATA[ -nmake php_sam.dll -]]> - </screen> -Also if you are using the XMS support you must make the sam_xms extensions: - <screen> - <![CDATA[ -nmake php_sam_xms.dll -]]> - </screen> - </para> - <para> -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. - </para> - <para> -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 - &php.ini; - : - <screen> - <![CDATA[ -extension=php_sam.dll -]]> - </screen> - If you intend to use the XMS support to access the IBM Messgaing and Queuing family - you must also enable the SAM XMS extension. - <screen> - <![CDATA[ -extension=php_sam_xms.dll -]]> - </screen> - </para> - </section> - <section xml:id='sam.installation.VS2005'> - <title>Additional steps for Visual Studio 2005</title> - <para> - 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 <filename>php_sam.dll</filename> 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 - <filename>php_sam.dll</filename> has been generated (usually - Release_TS or Debug_TS below the php source directory) and issue the - following magic incantation: - <screen> -<![CDATA[ -mt.exe -manifest php_sam.dll.manifest -outputresource:php_sam.dll;2 -]]> - </screen> -If you are using the XMS capabilities you will need to do the same with the -SAM XMS DLL: - <screen> - <![CDATA[ -mt.exe -manifest php_sam_xms.dll.manifest -outputresource:php_sam_xms.dll;2 -]]> - </screen> - </para> - <para> - 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 - <link xlink:href="&url.ms.crt;">runtime package</link>. - </para> - </section> - <section xml:id='sam.installation.configutaion'> - <title>Protocol support and mapping</title> - <para> -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. - </para> - <para> -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 &php.ini; in the [sam] section. The -default mapping is equivalent to the following entries: - <screen> - <![CDATA[ -[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 -]]> - </screen> -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. - </para> - <para> -When identifying the support code to use on a connect call SAM looks up the protocol name in the &php.ini; entries -and then invokes a factory script named sam_factory_xxx.php. If no entry is found the support will default to XMS. - </para> - </section> - </section> <!-- xml:id=sam.installation --> - - <section xml:id='sam.usage'> - <title>API Usage</title> - - <section xml:id='sam.connections'> - <title>Connections</title> - <para> - 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. - </para> - <para> - 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. - </para> - <para> - <example> - <title>Creating a connection and connecting to a remote WebSphere MQSeries Messaging Server</title> - <programlisting role='php'> -<![CDATA[ -<?php - $conn = new SAMConnection(); - $conn->connect(SAM_WMQ, array(SAM_HOST => 'myhost.mycompany.com', - SAM_PORT => 1506, - SAM_BROKER => 'mybroker')); -?> -]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Creating a connection and connecting to a remote WebSphere Application Server</title> - <programlisting role='php'> -<![CDATA[ -<?php - $conn = new SAMConnection(); - $conn->connect(SAM_WPM, array(SAM_ENDPOINTS => 'localhost:7278:BootstrapBasicMessaging', - SAM_BUS => 'Bus1', - SAM_TARGETCHAIN => 'InboundBasicMessaging')); -?> -]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Creating a connection and connecting to an MQTT server</title> - <programlisting role='php'> - <![CDATA[ -<?php - $conn = new SAMConnection(); - $conn->connect(SAM_MQTT, array(SAM_HOST => 'myhost.mycompany.com', - SAM_PORT => 1883)); -?> - ]]> - </programlisting> - </example> - </para> - </section> <!-- xml:id=sam.connections --> - - <section xml:id='sam.messages'> - <title>Messages</title> - <para> - 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. - </para> - <para> - <example> - <title>Creating a message with a simple text body</title> - <programlisting role="php"> -<![CDATA[ -<?php -$msg = new SAMMessage('This is a simple text message'); -?> -]]> - </programlisting> - </example> - </para> - <para> - 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: - </para> - <para> - <example> - <title>Setting a text format property using the default syntax</title> - <programlisting role="php"> -<![CDATA[ -<?php - $msg->header->myPropertyName = 'textData'; -?> -]]> - </programlisting> - </example> - </para> - <para> - 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: - </para> - <para> - <example> - <title>Setting a property using a type hint</title> - <programlisting role="php"> -<![CDATA[ -<?php - $msg->header->myPropertyName = array(3.14159, SAM_FLOAT); -?> -]]> - </programlisting> - </example> - </para> - <para> - Properties may also be extracted from the header of a message. - </para> - <para> - <example> - <title>Retrieving a property from a message header</title> - <programlisting role="php"> -<![CDATA[ -<?php - $myProperty = $msg->header->myPropertyName; -?> -]]> - </programlisting> - </example> - </para> - </section> <!-- xml:id=sam.messages --> - - <section xml:id='sam.operations'> - <title>Messaging operations</title> - <para> - 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. - </para> - <para> - <example> - <title>Adding a message to a queue and receiving a response</title> - <programlisting role="php"> -<![CDATA[ -<?php -$msg = new SAMMessage('This is a simple text message'); -$msg->header->SAM_REPLY_TO = 'queue://receive/test'; -$correlid = $conn->send('queue://send/test', $msg); - -if (!$correlid) { - // The Send failed! - echo "Send failed ($conn->errno) $conn->error"; -} else { - $resp = $conn->receive('queue://receive/test', array(SAM_CORRELID => $correlid)); -} -?> -]]> - </programlisting> - </example> - </para> - </section> <!-- xml:id=sam.operations --> - <section xml:id='sam.pubsub'> - <title>Publish/Subscribe and suscriptions to topics</title> - <para> - 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. - </para> - <para> - 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. - </para> - <para> - 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. - </para> - <para> - <example> - <title>Creating a durable subscription to a topic</title> - <programlisting role="php"> -<![CDATA[ -<?php - -$subName = $conn->subscribe('topic://A'); - -if (!$subName) { - echo "Subscribe failed"; -} else { - # Subscribe was OK - // ... -} -?> -]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Subscribing to a topic using a WebSphere Platform Messaging (WPM) server</title> - <programlisting role="php"> -<![CDATA[ -<?php -$conn = new SAMConnection(); -// Note: For pub/sub on WPM, when connecting the name of a messaging engine -// to hold the durable subscription (SAM_WPM_DUR_SUB_HOME) must be specified. -$conn->connect(SAM_WMQ, array(SAM_ENDPOINTS => 'localhost:7278:BootstrapBasicMessaging', - SAM_BUS => 'Bus1', - SAM_TARGETCHAIN => 'InboundBasicMessaging' - SAM_WPM_DUR_SUB_HOME => 'MyMachineNode01.server1-Bus1')); - -$subName = $conn->subscribe('topic://A'); - -if (!$subName) { - echo "Subscribe failed"; -} else { - # Subscribe was OK - // ... -} -?> -]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Receiving published data using a durable subscription</title> - <programlisting role="php"> -<![CDATA[ -<?php - -$msg = $conn->receive($subName); -if ($msg) { - echo "Received a message OK"; -} else { - echo "The receive failed"; -} - -?> -]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Deleting a durable subscription to a topic</title> - <programlisting role="php"> -<![CDATA[ -<?php - -if (!$conn->unsubscribe($subName)) { - echo "Unsubscribe failed"; -} - -?> -]]> - </programlisting> - </example> - </para> - </section> <!-- xml:id=sam.pubsub --> - <section xml:id='sam.errors'> - <title>Error handling</title> - <para> - All SAMConnection methods that provide access to messaging operations - return &false; 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. - </para> - <para> - <example> - <title>Handling an error from a method that returns no result</title> - <programlisting role="php"> - <![CDATA[ -<?php - if (!$conn->commit()) { - // The commit failed! - echo "Commit failed ($conn->errno) $conn->error"; - } -?> - ]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Handling an error from a method that returns a result</title> - <programlisting role="php"> -<![CDATA[ -<?php -$correlid = $conn->send('queue://send/test', $msg); - -if (!$correlid) { - // The Send failed! - echo "Send failed ($conn->errno) $conn->error"; -} else { - ... -} -?> -]]> - </programlisting> - </example> - </para> - </section> <!-- xml:id=sam.errors --> - </section> <!-- xml:id=sam.usage --> + <!-- FIXME: Upgrade to the new-oo-markup --> <!-- class definition section --> <section xml:id='sam.classes'> &reftitle.classes; @@ -827,9 +178,6 @@ </section> <!-- xml:id=sam.classes --> - <!-- Include the stuff from constants.xml? --> - &reference.sam.constants; - </partintro> <!-- This seems to create the table of contents --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/sam/constants.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/sam/constants.xml diff -u phpdoc/en/reference/sam/constants.xml:1.8 phpdoc/en/reference/sam/constants.xml:1.9 --- phpdoc/en/reference/sam/constants.xml:1.8 Wed Jun 20 22:25:18 2007 +++ phpdoc/en/reference/sam/constants.xml Fri Dec 21 20:27:30 2007 @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='iso-8859-1'?> -<!-- $Revision: 1.8 $ --> -<section xml:id="mq.constants" xmlns="http://docbook.org/ns/docbook"> +<!-- $Revision: 1.9 $ --> +<appendix xml:id="sam.constants" xmlns="http://docbook.org/ns/docbook"> &reftitle.constants; &extension.constants; <variablelist> @@ -427,7 +427,7 @@ </listitem> </varlistentry> </variablelist> -</section> +</appendix> <!-- Keep this comment at the end of the file Local variables:
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/sam/book.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/en/reference/sam/book.xml diff -u /dev/null phpdoc/en/reference/sam/book.xml:1.2 --- /dev/null Fri Dec 21 20:27:30 2007 +++ phpdoc/en/reference/sam/book.xml Fri Dec 21 20:27:30 2007 @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.2 $ --> +<!-- Purpose: remote.other --> +<!-- Membership: pecl --> + +<book xml:id="book.sam" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + <title>Simple Asynchronous Messaging</title> + + <!-- {{{ preface --> + <preface xml:id="intro.sam"> + &reftitle.intro; + <para> + 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. + </para> + <para> + 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. + </para> + </preface> + <!-- }}} --> + + &reference.sam.setup; + &reference.sam.constants; + &reference.sam.examples; + &reference.sam.reference; + +</book> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> + http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/sam/setup.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/en/reference/sam/setup.xml diff -u /dev/null phpdoc/en/reference/sam/setup.xml:1.2 --- /dev/null Fri Dec 21 20:27:30 2007 +++ phpdoc/en/reference/sam/setup.xml Fri Dec 21 20:27:30 2007 @@ -0,0 +1,351 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.2 $ --> + +<chapter xml:id="sam.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + &reftitle.setup; + + <!-- {{{ Requirements --> + <section xml:id="sam.requirements"> + &reftitle.required; + <para> + 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 <link xlink:href="&url.ibm.ia94;"> + Introducing XMS - The IBM Message Service API</link>. + </para> + <para> + 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 (<link xlink:href="&url.ibm.mqc6;">MQC6</link>). + </para> + <para> + 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. + </para> + <para> + 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. + </para> + </section> + <!-- }}} --> + + <!-- {{{ Installation --> + <section xml:id="sam.installation"> + &reftitle.install; + <para> + 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. + </para> + <para> + 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: + <screen> +<![CDATA[ +pecl install -B SAM +]]> + </screen> + </para> + + <!-- {{{ Linux --> + <section xml:id='sam.installation.linux'> + <title>Linux installation steps</title> + <para> + The sam extension is supplied as a PECL module, which + you should be able to download and install in one step as follows: + <screen> +<![CDATA[ +pecl install sam +]]> + </screen> + (Depending on your php environment, you will probably need to be root + to do this.) + </para> + <para> + Make sure that the module is loaded by PHP, by adding following line + to &php.ini;: + <screen> +<![CDATA[ +extension=sam.so +]]> + </screen> + If you intend to use the XMS support to access the IBM Messaging and Queuing family + you must also enable the SAM XMS extension. + <screen> +<![CDATA[ +extension=sam_xms.so +]]> + </screen> + </para> + <para> + If you cannot use the PEAR installer, you can download the extension + and build it manually: + <screen> +<![CDATA[ +pear download sam #downloads sam-<version>.tgz +tar -xzf sam-<version>.tgz +cd sam-<version> +phpize +./configure +make +make install #you may need to be root for this step +]]> + </screen> + </para> + <para> + To work with the very latest source, you'll need to extract it from + cvs and build manually as above. + </para> + </section> + <!-- }}} --> + <!-- {{{ Windows --> + <section xml:id='sam.installation.windows'> + <title>Windows installation steps</title> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + You should have something like: + <screen> +<![CDATA[ +c:\php-build\- + | + |---php-5.0.5--|---build + | |---ext + | |--- ... + | + |---win32build--|---bin + |---include + |---lib +]]> + </screen> + </para> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + To build the extension open a build environment window by going to the + start menu->all programs->microsoft platform SDK for windows-> + open build environment window->windows 200 build environment-> + set windows 2000 build environment (retail) + </para> + <para> + 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. + </para> + <para> + 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: + <screen> +<![CDATA[ +set PATH=..\win32build\bin;%PATH% +]]> + </screen> + </para> + <para> + Run the buildconf.bat command. This should rebuild the configure.js + file. + </para> + <para> + Run the cscript command with the appropriate options. To build just the + SAM extension framework and MQTT support use: + <screen> +<![CDATA[ +cscript /nologo configure.js --with-sam +]]> + </screen> + To build the SAM framework and the XMS support use: + <screen> +<![CDATA[ +cscript /nologo configure.js --with-sam --with-sam_xms="c:\program files\ibm\xms" +]]> + </screen> + </para> + <para> + 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. + </para> + <para> + You can specify whatever other cscript parameters you require to + include or exclude items from the php build or select options. + </para> + <para> + Assuming all has gone well so far you can now finally run a make for the SAM framework! + <screen> +<![CDATA[ +nmake php_sam.dll +]]> + </screen> + Also if you are using the XMS support you must make the sam_xms extensions: + <screen> +<![CDATA[ +nmake php_sam_xms.dll +]]> + </screen> + </para> + <para> + 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. + </para> + <para> + 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 &php.ini;: + <screen> +<![CDATA[ +extension=php_sam.dll +]]> + </screen> + If you intend to use the XMS support to access the IBM Messgaing and Queuing family + you must also enable the SAM XMS extension. + <screen> +<![CDATA[ +extension=php_sam_xms.dll +]]> + </screen> + </para> + </section> + <!-- }}} --> + <!-- {{{ VS2005 --> + <section xml:id='sam.installation.VS2005'> + <title>Additional steps for Visual Studio 2005</title> + <para> + 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 <filename>php_sam.dll</filename> 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 + <filename>php_sam.dll</filename> has been generated (usually + Release_TS or Debug_TS below the php source directory) and issue the + following magic incantation: + <screen> +<![CDATA[ +mt.exe -manifest php_sam.dll.manifest -outputresource:php_sam.dll;2 +]]> + </screen> + If you are using the XMS capabilities you will need to do the same with the + SAM XMS DLL: + <screen> +<![CDATA[ +mt.exe -manifest php_sam_xms.dll.manifest -outputresource:php_sam_xms.dll;2 +]]> + </screen> + </para> + <para> + 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 + <link xlink:href="&url.ms.crt;">runtime package</link>. + </para> + </section> + <!-- }}} --> + </section> + <!-- }}} --> + + <!-- {{{ Configuration --> + <section xml:id="sam.configuration"> + &reftitle.runtime; + <section xml:id="sam.configuration.mapping"> + <title>Protocol support and mapping</title> + <para> + 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. + </para> + <para> + 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 &php.ini; in the [sam] section. The + default mapping is equivalent to the following entries: + <screen> +<![CDATA[ +[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 +]]> + </screen> + 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. + </para> + <para> + When identifying the support code to use on a connect call SAM looks up the protocol name in the &php.ini; entries + and then invokes a factory script named sam_factory_xxx.php. If no entry is found the support will default to XMS. + </para> + </section> + </section> + <!-- }}} --> + + <!-- {{{ Resources --> + <section xml:id="sam.resources"> + &reftitle.resources; + &no.resource; + </section> + <!-- }}} --> + +</chapter> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> + http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/sam/examples.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/en/reference/sam/examples.xml diff -u /dev/null phpdoc/en/reference/sam/examples.xml:1.2 --- /dev/null Fri Dec 21 20:27:30 2007 +++ phpdoc/en/reference/sam/examples.xml Fri Dec 21 20:27:30 2007 @@ -0,0 +1,357 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.2 $ --> + +<chapter xml:id="sam.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + &reftitle.examples; + <section xml:id='sam.connections'> + <title>Connections</title> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + <example> + <title>Creating a connection and connecting to a remote WebSphere MQSeries Messaging Server</title> + <programlisting role='php'> +<![CDATA[ +<?php +$conn = new SAMConnection(); +$conn->connect(SAM_WMQ, array(SAM_HOST => 'myhost.mycompany.com', + SAM_PORT => 1506, + SAM_BROKER => 'mybroker')); +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Creating a connection and connecting to a remote WebSphere Application Server</title> + <programlisting role='php'> +<![CDATA[ +<?php +$conn = new SAMConnection(); +$conn->connect(SAM_WPM, array(SAM_ENDPOINTS => 'localhost:7278:BootstrapBasicMessaging', + SAM_BUS => 'Bus1', + SAM_TARGETCHAIN => 'InboundBasicMessaging')); +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Creating a connection and connecting to an MQTT server</title> + <programlisting role='php'> +<![CDATA[ +<?php +$conn = new SAMConnection(); +$conn->connect(SAM_MQTT, array(SAM_HOST => 'myhost.mycompany.com', + SAM_PORT => 1883)); +?> +]]> + </programlisting> + </example> + </para> + </section> <!-- xml:id=sam.connections --> + + <section xml:id='sam.messages'> + <title>Messages</title> + <para> + 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. + </para> + <para> + <example> + <title>Creating a message with a simple text body</title> + <programlisting role="php"> +<![CDATA[ +<?php +$msg = new SAMMessage('This is a simple text message'); +?> +]]> + </programlisting> + </example> + </para> + <para> + 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: + </para> + <para> + <example> + <title>Setting a text format property using the default syntax</title> + <programlisting role="php"> +<![CDATA[ +<?php +$msg->header->myPropertyName = 'textData'; +?> +]]> + </programlisting> + </example> + </para> + <para> + 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: + </para> + <para> + <example> + <title>Setting a property using a type hint</title> + <programlisting role="php"> +<![CDATA[ +<?php +$msg->header->myPropertyName = array(3.14159, SAM_FLOAT); +?> +]]> + </programlisting> + </example> + </para> + <para> + Properties may also be extracted from the header of a message. + </para> + <para> + <example> + <title>Retrieving a property from a message header</title> + <programlisting role="php"> +<![CDATA[ +<?php +$myProperty = $msg->header->myPropertyName; +?> +]]> + </programlisting> + </example> + </para> + </section> <!-- xml:id=sam.messages --> + + <section xml:id='sam.operations'> + <title>Messaging operations</title> + <para> + 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. + </para> + <para> + <example> + <title>Adding a message to a queue and receiving a response</title> + <programlisting role="php"> +<![CDATA[ +<?php +$msg = new SAMMessage('This is a simple text message'); +$msg->header->SAM_REPLY_TO = 'queue://receive/test'; +$correlid = $conn->send('queue://send/test', $msg); + +if (!$correlid) { + // The Send failed! + echo "Send failed ($conn->errno) $conn->error"; +} else { + $resp = $conn->receive('queue://receive/test', array(SAM_CORRELID => $correlid)); +} +?> +]]> + </programlisting> + </example> + </para> + </section> <!-- xml:id=sam.operations --> + + <section xml:id='sam.pubsub'> + <title>Publish/Subscribe and suscriptions to topics</title> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + 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. + </para> + <para> + <example> + <title>Creating a durable subscription to a topic</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$subName = $conn->subscribe('topic://A'); + +if (!$subName) { + echo "Subscribe failed"; +} else { + # Subscribe was OK + // ... +} +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Subscribing to a topic using a WebSphere Platform Messaging (WPM) server</title> + <programlisting role="php"> +<![CDATA[ +<?php +$conn = new SAMConnection(); +// Note: For pub/sub on WPM, when connecting the name of a messaging engine +// to hold the durable subscription (SAM_WPM_DUR_SUB_HOME) must be specified. +$conn->connect(SAM_WMQ, array(SAM_ENDPOINTS => 'localhost:7278:BootstrapBasicMessaging', + SAM_BUS => 'Bus1', + SAM_TARGETCHAIN => 'InboundBasicMessaging' + SAM_WPM_DUR_SUB_HOME => 'MyMachineNode01.server1-Bus1')); + +$subName = $conn->subscribe('topic://A'); + +if (!$subName) { + echo "Subscribe failed"; +} else { + # Subscribe was OK + // ... +} +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Receiving published data using a durable subscription</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$msg = $conn->receive($subName); +if ($msg) { + echo "Received a message OK"; +} else { + echo "The receive failed"; +} + +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Deleting a durable subscription to a topic</title> + <programlisting role="php"> +<![CDATA[ +<?php + +if (!$conn->unsubscribe($subName)) { + echo "Unsubscribe failed"; +} + +?> +]]> + </programlisting> + </example> + </para> + </section> <!-- xml:id=sam.pubsub --> + + <section xml:id='sam.errors'> + <title>Error handling</title> + <para> + All SAMConnection methods that provide access to messaging operations + return &false; 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. + </para> + <para> + <example> + <title>Handling an error from a method that returns no result</title> + <programlisting role="php"> +<![CDATA[ +<?php +if (!$conn->commit()) { + // The commit failed! + echo "Commit failed ($conn->errno) $conn->error"; +} +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> + <title>Handling an error from a method that returns a result</title> + <programlisting role="php"> +<![CDATA[ +<?php +$correlid = $conn->send('queue://send/test', $msg); + +if (!$correlid) { + // The Send failed! + echo "Send failed ($conn->errno) $conn->error"; +} else { + ... +} +?> +]]> + </programlisting> + </example> + </para> + </section> <!-- xml:id=sam.errors --> + +</chapter> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> + http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/sam/reference.xml?r1=1.10&r2=1.11&diff_format=u Index: phpdoc/en/reference/sam/reference.xml diff -u phpdoc/en/reference/sam/reference.xml:1.10 phpdoc/en/reference/sam/reference.xml:1.11 --- phpdoc/en/reference/sam/reference.xml:1.10 Mon Dec 10 17:06:08 2007 +++ phpdoc/en/reference/sam/reference.xml Fri Dec 21 20:27:30 2007 @@ -1,660 +1,11 @@ <?xml version='1.0' encoding='iso-8859-1'?> -<!-- $Revision: 1.10 $ --> -<!-- Purpose: remote.other --> -<!-- Membership: pecl --> +<!-- $Revision: 1.11 $ --> <reference xml:id="ref.sam" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> - <title>SAM - Simple Asynchronous Messaging</title> - <titleabbrev>SAM</titleabbrev> + <title>SAM &Functions;</title> <partintro> - <section xml:id="sam.intro"> - &reftitle.intro; - <para> - 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. - </para> - <para> - 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. - </para> - </section> <!-- xml:id=sam.intro --> - - <section xml:id='sam.installation'> - &reftitle.install; - <para> - 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. - </para> - <para> - 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: - <screen> - <![CDATA[ - pecl install -B SAM -]]> - </screen> - </para> - <section xml:id='sam.installation.prerequisites'> - <title>Prerequisites</title> - <para> - 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 <link xlink:href="&url.ibm.ia94;"> - Introducing XMS - The IBM Message Service API</link>. - </para> - <para> - 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 (<link xlink:href="&url.ibm.mqc6;">MQC6</link>). - </para> - <para> - 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. - </para> - <para> - 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. - </para> - </section> - <section xml:id='sam.installation.linux'> - <title>Linux installation steps</title> - <para> -The sam extension is supplied as a PECL module, which -you should be able to download and install in one step as follows: - <screen> - <![CDATA[ -pecl install sam -]]> - </screen> - (Depending on your php environment, you will probably need to be root - to do this.) - </para> - <para> - Make sure that the module is loaded by PHP, by adding following line - to &php.ini;: - <screen> -<![CDATA[ -extension=sam.so -]]> - </screen> - If you intend to use the XMS support to access the IBM Messaging and Queuing family - you must also enable the SAM XMS extension. - <screen> - <![CDATA[ -extension=sam_xms.so -]]> - </screen> - </para> - <para> -If you cannot use the PEAR installer, you can download the extension and build -it manually: - <screen> -<![CDATA[ -pear download sam #downloads sam-<version>.tgz -tar -xzf sam-<version>.tgz -cd sam-<version> -phpize -./configure -make -make install #you may need to be root for this step -]]> - </screen> - </para> - <para> - To work with the very latest source, you'll need to extract it from - cvs and build manually as above. - </para> - </section> - <section xml:id='sam.installation.windows'> - <title>Windows installation steps</title> - <para> -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. - </para> - <para> - 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. - </para> - <para> - 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. - </para> - <para> - You should have something like: - <screen> -<![CDATA[ -c:\php-build\- - | - |---php-5.0.5--|---build - | |---ext - | |--- ... - | - |---win32build--|---bin - |---include - |---lib -]]> - </screen> - </para> - <para> - 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. - </para> - <para> -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. - </para> - <para> - To build the extension open a build environment window by going to the - start menu->all programs->microsoft platform SDK for windows-> - open build environment window->windows 200 build environment-> - set windows 2000 build environment (retail) - </para> - <para> - 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. - </para> - <para> - 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: - <screen> -<![CDATA[ -set PATH=..\win32build\bin;%PATH% -]]> - </screen> - </para> - <para> - Run the buildconf.bat command. This should rebuild the configure.js - file. - </para> - <para> -Run the cscript command with the appropriate options. To build just the -SAM extension framework and MQTT support use: - <screen> - <![CDATA[ -cscript /nologo configure.js --with-sam -]]> - </screen> -To build the SAM framework and the XMS support use: - <screen> - <![CDATA[ -cscript /nologo configure.js --with-sam --with-sam_xms="c:\program files\ibm\xms" -]]> - </screen> - </para> - <para> -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. - </para> - <para> - You can specify whatever other cscript parameters you require to - include or exclude items from the php build or select options. - </para> - <para> -Assuming all has gone well so far you can now finally run a make for the SAM framework! - <screen> - <![CDATA[ -nmake php_sam.dll -]]> - </screen> -Also if you are using the XMS support you must make the sam_xms extensions: - <screen> - <![CDATA[ -nmake php_sam_xms.dll -]]> - </screen> - </para> - <para> -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. - </para> - <para> -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 - &php.ini; - : - <screen> - <![CDATA[ -extension=php_sam.dll -]]> - </screen> - If you intend to use the XMS support to access the IBM Messgaing and Queuing family - you must also enable the SAM XMS extension. - <screen> - <![CDATA[ -extension=php_sam_xms.dll -]]> - </screen> - </para> - </section> - <section xml:id='sam.installation.VS2005'> - <title>Additional steps for Visual Studio 2005</title> - <para> - 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 <filename>php_sam.dll</filename> 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 - <filename>php_sam.dll</filename> has been generated (usually - Release_TS or Debug_TS below the php source directory) and issue the - following magic incantation: - <screen> -<![CDATA[ -mt.exe -manifest php_sam.dll.manifest -outputresource:php_sam.dll;2 -]]> - </screen> -If you are using the XMS capabilities you will need to do the same with the -SAM XMS DLL: - <screen> - <![CDATA[ -mt.exe -manifest php_sam_xms.dll.manifest -outputresource:php_sam_xms.dll;2 -]]> - </screen> - </para> - <para> - 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 - <link xlink:href="&url.ms.crt;">runtime package</link>. - </para> - </section> - <section xml:id='sam.installation.configutaion'> - <title>Protocol support and mapping</title> - <para> -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. - </para> - <para> -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 &php.ini; in the [sam] section. The -default mapping is equivalent to the following entries: - <screen> - <![CDATA[ -[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 -]]> - </screen> -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. - </para> - <para> -When identifying the support code to use on a connect call SAM looks up the protocol name in the &php.ini; entries -and then invokes a factory script named sam_factory_xxx.php. If no entry is found the support will default to XMS. - </para> - </section> - </section> <!-- xml:id=sam.installation --> - - <section xml:id='sam.usage'> - <title>API Usage</title> - - <section xml:id='sam.connections'> - <title>Connections</title> - <para> - 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. - </para> - <para> - 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. - </para> - <para> - <example> - <title>Creating a connection and connecting to a remote WebSphere MQSeries Messaging Server</title> - <programlisting role='php'> -<![CDATA[ -<?php - $conn = new SAMConnection(); - $conn->connect(SAM_WMQ, array(SAM_HOST => 'myhost.mycompany.com', - SAM_PORT => 1506, - SAM_BROKER => 'mybroker')); -?> -]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Creating a connection and connecting to a remote WebSphere Application Server</title> - <programlisting role='php'> -<![CDATA[ -<?php - $conn = new SAMConnection(); - $conn->connect(SAM_WPM, array(SAM_ENDPOINTS => 'localhost:7278:BootstrapBasicMessaging', - SAM_BUS => 'Bus1', - SAM_TARGETCHAIN => 'InboundBasicMessaging')); -?> -]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Creating a connection and connecting to an MQTT server</title> - <programlisting role='php'> - <![CDATA[ -<?php - $conn = new SAMConnection(); - $conn->connect(SAM_MQTT, array(SAM_HOST => 'myhost.mycompany.com', - SAM_PORT => 1883)); -?> - ]]> - </programlisting> - </example> - </para> - </section> <!-- xml:id=sam.connections --> - - <section xml:id='sam.messages'> - <title>Messages</title> - <para> - 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. - </para> - <para> - <example> - <title>Creating a message with a simple text body</title> - <programlisting role="php"> -<![CDATA[ -<?php -$msg = new SAMMessage('This is a simple text message'); -?> -]]> - </programlisting> - </example> - </para> - <para> - 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: - </para> - <para> - <example> - <title>Setting a text format property using the default syntax</title> - <programlisting role="php"> -<![CDATA[ -<?php - $msg->header->myPropertyName = 'textData'; -?> -]]> - </programlisting> - </example> - </para> - <para> - 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: - </para> - <para> - <example> - <title>Setting a property using a type hint</title> - <programlisting role="php"> -<![CDATA[ -<?php - $msg->header->myPropertyName = array(3.14159, SAM_FLOAT); -?> -]]> - </programlisting> - </example> - </para> - <para> - Properties may also be extracted from the header of a message. - </para> - <para> - <example> - <title>Retrieving a property from a message header</title> - <programlisting role="php"> -<![CDATA[ -<?php - $myProperty = $msg->header->myPropertyName; -?> -]]> - </programlisting> - </example> - </para> - </section> <!-- xml:id=sam.messages --> - - <section xml:id='sam.operations'> - <title>Messaging operations</title> - <para> - 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. - </para> - <para> - <example> - <title>Adding a message to a queue and receiving a response</title> - <programlisting role="php"> -<![CDATA[ -<?php -$msg = new SAMMessage('This is a simple text message'); -$msg->header->SAM_REPLY_TO = 'queue://receive/test'; -$correlid = $conn->send('queue://send/test', $msg); - -if (!$correlid) { - // The Send failed! - echo "Send failed ($conn->errno) $conn->error"; -} else { - $resp = $conn->receive('queue://receive/test', array(SAM_CORRELID => $correlid)); -} -?> -]]> - </programlisting> - </example> - </para> - </section> <!-- xml:id=sam.operations --> - <section xml:id='sam.pubsub'> - <title>Publish/Subscribe and suscriptions to topics</title> - <para> - 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. - </para> - <para> - 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. - </para> - <para> - 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. - </para> - <para> - <example> - <title>Creating a durable subscription to a topic</title> - <programlisting role="php"> -<![CDATA[ -<?php - -$subName = $conn->subscribe('topic://A'); - -if (!$subName) { - echo "Subscribe failed"; -} else { - # Subscribe was OK - // ... -} -?> -]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Subscribing to a topic using a WebSphere Platform Messaging (WPM) server</title> - <programlisting role="php"> -<![CDATA[ -<?php -$conn = new SAMConnection(); -// Note: For pub/sub on WPM, when connecting the name of a messaging engine -// to hold the durable subscription (SAM_WPM_DUR_SUB_HOME) must be specified. -$conn->connect(SAM_WMQ, array(SAM_ENDPOINTS => 'localhost:7278:BootstrapBasicMessaging', - SAM_BUS => 'Bus1', - SAM_TARGETCHAIN => 'InboundBasicMessaging' - SAM_WPM_DUR_SUB_HOME => 'MyMachineNode01.server1-Bus1')); - -$subName = $conn->subscribe('topic://A'); - -if (!$subName) { - echo "Subscribe failed"; -} else { - # Subscribe was OK - // ... -} -?> -]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Receiving published data using a durable subscription</title> - <programlisting role="php"> -<![CDATA[ -<?php - -$msg = $conn->receive($subName); -if ($msg) { - echo "Received a message OK"; -} else { - echo "The receive failed"; -} - -?> -]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Deleting a durable subscription to a topic</title> - <programlisting role="php"> -<![CDATA[ -<?php - -if (!$conn->unsubscribe($subName)) { - echo "Unsubscribe failed"; -} - -?> -]]> - </programlisting> - </example> - </para> - </section> <!-- xml:id=sam.pubsub --> - <section xml:id='sam.errors'> - <title>Error handling</title> - <para> - All SAMConnection methods that provide access to messaging operations - return &false; 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. - </para> - <para> - <example> - <title>Handling an error from a method that returns no result</title> - <programlisting role="php"> - <![CDATA[ -<?php - if (!$conn->commit()) { - // The commit failed! - echo "Commit failed ($conn->errno) $conn->error"; - } -?> - ]]> - </programlisting> - </example> - </para> - <para> - <example> - <title>Handling an error from a method that returns a result</title> - <programlisting role="php"> -<![CDATA[ -<?php -$correlid = $conn->send('queue://send/test', $msg); - -if (!$correlid) { - // The Send failed! - echo "Send failed ($conn->errno) $conn->error"; -} else { - ... -} -?> -]]> - </programlisting> - </example> - </para> - </section> <!-- xml:id=sam.errors --> - </section> <!-- xml:id=sam.usage --> + <!-- FIXME: Upgrade to the new-oo-markup --> <!-- class definition section --> <section xml:id='sam.classes'> &reftitle.classes; @@ -827,9 +178,6 @@ </section> <!-- xml:id=sam.classes --> - <!-- Include the stuff from constants.xml? --> - &reference.sam.constants; - </partintro> <!-- This seems to create the table of contents --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/sam/constants.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/sam/constants.xml diff -u phpdoc/en/reference/sam/constants.xml:1.8 phpdoc/en/reference/sam/constants.xml:1.9 --- phpdoc/en/reference/sam/constants.xml:1.8 Wed Jun 20 22:25:18 2007 +++ phpdoc/en/reference/sam/constants.xml Fri Dec 21 20:27:30 2007 @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='iso-8859-1'?> -<!-- $Revision: 1.8 $ --> -<section xml:id="mq.constants" xmlns="http://docbook.org/ns/docbook"> +<!-- $Revision: 1.9 $ --> +<appendix xml:id="sam.constants" xmlns="http://docbook.org/ns/docbook"> &reftitle.constants; &extension.constants; <variablelist> @@ -427,7 +427,7 @@ </listitem> </varlistentry> </variablelist> -</section> +</appendix> <!-- Keep this comment at the end of the file Local variables: