PHP: SAMConnection::connect() - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

SAMConnection::SAMConnection() SAMConnection::commit()

Last updated: Sat, 27 Jan 2007

view this page in

# SAMConnection::connect()

(no version information, might be only in CVS)

SAMConnection::connect() -- Establishes a connection to a Messaging Server

## Описание

Calling the "connect" method on a SAMConnection object connects the PHP script to a messaging server. No messages can be sent or received until a connection is made.

class SAMConnection {
bool connect ( string protocol [, array properties] )
}

## Список параметров

`protocol`

  A structured string identifying the protocol to be used when attempting to connect to the messaging server. The supported protocols are represented by constants which are normally used but if required the string may be composed dynamically by the script. The string is made up of 2 parts, the first being the protocol identifier and the second a protocol option. The two parts are seperated by a colon (:) character. Acceptable values are described by the following table:

  Protocol string | Constant | Usage
  --- | --- | ---
  wmq | SAM_WMQ | Use the IBM MQSeries protocol connecting as a client to a remote messaging server. This is equivalent to "wmq:client" (SAM_WMQ_CLIENT). At least a broker name (SAM_BROKER) must be specified in the options array.
  wmq:client | SAM_WMQ_CLIENT | Use the IBM MQSeries protocol connecting as a client to a remote messaging server. At least a broker name (SAM_BROKER) must be specified in the options array.
  wmq:bindings | SAM_WMQ_BINDINGS | Use the IBM MQSeries protocol connecting to a local messaging server and communicating via shared memory. At least a broker name (SAM_BROKER) must be specified in the options array.
  wpm | SAM_WPM | Use the IBM WebSphere Platform Messaging protocol to connect to the messaging infrastructure of a WebSphere Application server or cluster. A bus name must be specified in the options array (SAM_BUS) and endpoint and target chain may also be specified.
  rtt | SAM_RTT | Use the IBM Realtime transport protocol to connect to the messaging infrastructure.

`properties`

  An optional associative array of properties to describe the details of the connection required. The following table lists the available property names and accepted values:

  Property name | default | Usage
  --- | --- | ---
  SAM_BROKER | none | The name of the broker or queue manager running on the messaging server. This property must be set if using one of the variants of the WebSphere MQSeries protocol (SAM_WMQ, SAM_WMQ_CLIENT, SAM_WMQ_BINDINGS).
  SAM_HOST | localhost | The hostname of the machine on which the messaging server is running.
  SAM_PORT | 1414 for SAM_WMQ or 1506 for SAM_WPM | The port number on which to attempt communication with the messaging server.
  SAM_CLIENT_ID | none | A string used to uniquely identify the client when accessing subscriptions. Warning: Not yet implemented!
  SAM_EXPIRE_AFTER | 0 | Time in milliseconds after which a message is deemed to have expired and can be deleted from queues. The default value is 0 indicating the message never expires. Warning: Not yet implemented!
  SAM_MESSAGE_PERSISTENCE | none | Selects whether messages are made persistent during delivery. The value may be SAM_PERSISTENT or SAM_NON_PERSISTENT. The default is dependant on the connection type and capabilities of the Messaging Server to which the connection is made. Warning: Not yet implemented!
  SAM_PASSWORD | none | The password to be used when the Messaging Server to which the connection is being made requires authentication.
  SAM_TRANSACTIONS | SAM_AUTO | Indicates how transactions are handled on this connection. The value may be SAM_AUTO (the default) to allow automatic handling on a per operation basis or SAM_MANUAL to allow the PHP script to control the transaction boundaries. If SAM_MANUAL is used any in-flight transactions will be rolled back if the script is terminated or the connection is closed without a commit being executed.
  SAM_USERID | none | The user id to be used when the Messaging Server to which the connection is being made requires authentication.
  SAM_WPM_DUR_SUB_HOME | none | The name of the messaging engine where durable subscriptions are managed. (WPM ONLY).

## Возвращаемые значения

This method returns `FALSE` if an error occurs.

## Примеры

Пример 1. Creating a connection to a Messaging Server using the IBM MQSeries protocol (WMQ)

`<?php $conn->connect(SAM_WMQ, array(SAM_HOST => 'Myhost.myco.com', SAM_PORT => 1506, SAM_BROKER => 'MyBroker')); ?>`

Пример 2. Creating a connection with application transaction control and default host and port values

`<?php $conn->connect(SAM_WMQ, array(SAM_BROKER => 'MyBroker', SAM_TRANSACTIONS => SAM_MANUAL)); ?>`

Пример 3. Creating a connection to a Messaging Server using the IBM WebSphere Platform Messaging protocol (WPM)

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

add a note User Contributed Notes
SAMConnection::connect()
There are no user contributed notes for this page.
SAMConnection::SAMConnection() SAMConnection::commit()

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST