Connections

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.

Example #1 Creating a connection and connecting to a remote WebSphere MQSeries Messaging Server

<?php
$conn 
= new SAMConnection();
$conn->connect(SAM_WMQ, array(SAM_HOST => 'myhost.mycompany.com',
                              
SAM_PORT => 1506,
                              
SAM_BROKER => 'mybroker'));
?>

Example #2 Creating a connection and connecting to a remote WebSphere Application Server

<?php
$conn 
= new SAMConnection();
$conn->connect(SAM_WPM, array(SAM_ENDPOINTS => 'localhost:7278:BootstrapBasicMessaging',
                              
SAM_BUS => 'Bus1',
                              
SAM_TARGETCHAIN => 'InboundBasicMessaging'));
?>

Example #3 Creating a connection and connecting to an MQTT server

<?php
$conn 
= new SAMConnection();
$conn->connect(SAM_MQTT, array(SAM_HOST => 'myhost.mycompany.com',
                               
SAM_PORT => 1883));
?>

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top