Warning |
This extension is EXPERIMENTAL. The behaviour of this extension -- including the names of its functions and anything else documented about this extension -- may change without notice in a future release of PHP. Use this extension at your own risk. |
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.
This should be the installation section.
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.
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.
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.
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:
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:
Properties may also be extracted from the header of a message.
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.
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.
Object representing a connection to a Messaging Server
new SAMConnection - construct a new connection object to allow connection to a messaging infrastructure.
commit - a method that commits (successfully completes) an in-flight unit of work.
connect - a method that connects a PHP script to a messaging server.
disconnect - a method that disconnects a PHP script from a messaging server.
isConnected - a method that checks whether a PHP script is connected to a messaging server.
peek - a method that receives a message from a queue without removing it from the queue.
receive - a method that receives a message from a queue or subscription.
remove - a method that removes a message from a queue.
rollback - a method that cancels (rolls back) an in-flight unit of work.
send - a method that sends a message to a queue or posts to a topic
subscribe - a method that creates a subscription to one or more topics
unsubscribe - a method that destroys a subscription to one or more topics
Object representing a message to be sent or received
new SAMMessage - construct a new message.
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
Automatic behaviour
Type specifier used when setting properties on SAM_Message objects.
Connect attribute used to set the name of the enterprise service bus to connect to.
Type specifier used when setting properties on SAM_Message objects.
Message body type descriptor.
Message header property.
Type specifier used when setting properties on SAM_Message objects.
Connect attribute used to define the possible endpoints to connect to.
Type specifier used when setting properties on SAM_Message objects.
Connect attribute used to set the hostname of the required messaging server.
Type specifier used when setting properties on SAM_Message objects.
Type specifier used when setting properties on SAM_Message objects.
Manual (script controlled) behaviour
Connect attribute value used to request messages are not made persistent on the messaging server.
Connect attribute used to define the password to be used for the user account being used to connect to a messaging server that requires authorisation for connections.
Connect attribute value used to request messages are made persistent on the messaging server to protect against loss of messages in the event of failure.
Connect attribute used to set the port number on which to communicate with the messaging server.
Option name used on send requests to specify a delivery priority value.
Message propery used to specify the queue identity on to which the script expects response or reply messages to be posted.
Connect protocol definition for selecting the IBM Realtime Transport protocol for communication with a business integration messaging server.
Receive attribute used to set the required message selector.
Type specifier used when setting properties on SAM_Message objects.
Connection attribute used to set the required target chain identifier.
Message body type descriptor.
Message send option name used to specify the length of time a message should be retained in milliseconds.
Connection attribute used to set required transactional behaviour. May be set to SAM_AUTO (default) or SAM_MANUAL.
Connect attribute used to define the account to being used to connect to a messaging server that requires authorisation for connections.
Receive property used to specify the wait timeout to be used when receiving a message from a queue or subscription.
Connect protocol definition for selecting the IBM WebSphere MQSeries protocol for communication with the desired messaging server.
Connect protocol definition for selecting the IBM WebSphere MQSeries protocol for communication with a local messaging server.
Connect protocol definition for selecting the IBM WebSphere MQSeries protocol for communication with a remote messaging server.
Connect protocol definition for selecting the IBM WebSphere Platform Messaging protocol for communication with a WebSphere Application Server messaging server.