有没有人成功使用PHP / Linux连接到MQ?几天来,我一直在努力让这个工作,但无济于事。如果那里有人在做这件事,怎么样?
我认为有两种扩展可供使用: a)mqseries - > C API的薄包装器 b)SAM 1.1.0 - >采取更一般的方法
我已经尝试了两种方法,但是a)我能够成功地进行MQCONNX,但不能进行MQOPEN和b)我没有通过MQCONN阶段。我已经尝试了7和6客户端。我们的服务器运行6.0.0.0。
请注意;我们已成功使用.NET连接到服务器多年。
所以这就是我到目前为止所做的:
使用mqseries PECL扩展名,这是我得到的错误:
MQOPEN failed; CompCode:2 Reason:2044 Text:2044
使用SAM PECL扩展我得到了这个:
<--SAMConnection.SetDebug()
-->SAMConnection.Connect()
-->SAMConnection.Create(proto=wmq:client)
SAMConnection.Create() get_cfg_var() ""
SAMConnection.Create() calling factory - SAM/sam_factory_xms.php
SAMConnection.Create() rc = SAMXMSConnection
<--SAMConnection.Create()
SAMConnection.Connect() connection created for protocol wmq:client
SAMConnection.Connect() connect failed (208) Unable to create XMS connection!
<--SAMConnection.Connect() rc=
-->SAMConnection.IsConnected()
SAMConnection.IsConnected() isconnected failed (208) Unable to create XMS connection!
<--SAMConnection.IsConnected() rc=
Connection failed (208) Unable to create XMS connection!
这些错误都不会在/ var / mqm / errors中生成任何内容......
这是mqseries的示例代码:
mqseries_conn('MQED', $conn, $comp_code, $reason);
if ($comp_code !== MQSERIES_MQCC_OK) {
printf("<br>MQCONNX failed; Connx CompCode:%d Reason:%d Text:%s<br>\n", $comp_code, $reason, $reason);
exit;
}
else
{
printf("<br>MQCONNX successful: Connx CompCode:%d Reason:%d Text:%s<br>\n<br>", $comp_code, $reason, $reason);
}
$mqods = array('ObjectName'=>'MYPUTQUEUE');
mqseries_open($conn, $mqods,
MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT,
$obj, $comp_code,$reason);
if ($comp_code !== MQSERIES_MQCC_OK) {
printf("<br><br>MQOPEN failed; CompCode:%d Reason:%d Text:%s<br><br>",
$comp_code,
$reason,
$reason);
}
else
{
printf("<br><br>MQOPEN successful; CompCode:%d Reason:%d Text:%s<br><br>",
$comp_code,
$reason,
$reason);
}
以下是使用SAM扩展的示例代码:
$conn->connect(SAM_WMQ_CLIENT, array(SAM_BROKER => 'MQED',SAM_TRANSACTIONS => SAM_MANUAL));
if($conn->isConnected())
{
$msg = new SAMMessage('MY MESSAGE');
$msg->header->SAM_REPLY_TO = 'MYGETQUEUE';
$correlid = $conn->send('MYPUTQUEUE', $msg);
if (!$correlid) {
// The Send failed!
echo "Send failed ($conn->errno) $conn->error";
} else {
$resp = $conn->receive('MYGETQUEUE', array(SAM_CORRELID => $correlid));
}
$conn->disconnect();
}
else
{
echo "Connection failed ($conn->errno) $conn->error";
}
提前谢谢大家!
请注意,这是对Trying to connect to MQ using PHP; almost there
的讨论的延续更新#1:MQPUT1正常工作,但MQOPEN仍然返回2044。