尝试使用 PHP 连接 MQ;快到了
因此,过去几天我一直在尝试解决这个似乎已被遗忘的问题,因为两个可用的 PECL 扩展(SAM 和 mqseries)已经很长时间没有更新了。我已经尝试了这两种方法,而且 mqseries 似乎在这一点上让我走得最远,因为 SAM 拒绝为我提供连接,尽管 MQ 在命令行中工作得很好。我已经成功创建了到 QueueManager 的连接,但在下一步 (MQOPEN) 过程中我惨遭失败:
$mqcno = array(
'Version' => MQSERIES_MQCNO_VERSION_2,
'Options' => MQSERIES_MQCNO_STANDARD_BINDING,
'MQCD' => array('ChannelName' => '[channel]',
'ConnectionName' => '[ipnumber]([port])',
'TransportType' => MQSERIES_MQXPT_TCP)
);
mqseries_connx('MQED', $mqcno, $conn, $comp_code,$reason);
if ($comp_code !== MQSERIES_MQCC_OK) {
printf("Connx CompCode:%d Reason:%d Text:%s<br>\n", $comp_code, $reason, $reason);
exit;
}
$mqods = array('ObjectName'=>'MYPUTQUEUE', 'ObjectType'=>MQOT_Q, 'ObjectQMgrName'=>'MYQUEUEMANAGER');
mqseries_open($conn, $mqods,
MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT,
$obj, $comp_code,$reason);
这导致 $reason 被填充为 2044,翻译为 MQRC_OD_ERROR,或者用英语表示:“在 MQOPEN 或 MQPUT1 调用上” ,对象描述符 MQOD 无效'。
那么问题来了,我的 MQOD 出了什么问题?
更新#1:目前此问题尚未解决。我从头开始重建了该项目,以解决构建时的任何问题。我仍然停留在 MQOPEN 返回 2044 上。示例仍然可以从 CLI 完美运行,因此这肯定与 PECL 扩展的安装有关。如果有人在最近的 64 位 PHP5 环境中成功安装并在 MQ 上运行 PHP,请告诉我...
更新 #2:MQPUT1 完美地解决了我无法收到响应的问题。此时,只是 MQOPEN 不起作用。问题是;当 MQPUT1 工作时,是什么导致 MQOPEN 返回 2044,我理解其中包括 MQOPEN?
So I've spent the past few days trying to solve this that seems to have been forgotten since none of the two PECL extensions available (SAM and mqseries) have been updated for a long time. I've tried both and mqseries seems to get me the furthest at this point since SAM refuses to get me a connection, even though MQ works perfectly from the command line. I've successfully created a connection to my QueueManager and it's during the next step (MQOPEN) that I fail miserably:
$mqcno = array(
'Version' => MQSERIES_MQCNO_VERSION_2,
'Options' => MQSERIES_MQCNO_STANDARD_BINDING,
'MQCD' => array('ChannelName' => '[channel]',
'ConnectionName' => '[ipnumber]([port])',
'TransportType' => MQSERIES_MQXPT_TCP)
);
mqseries_connx('MQED', $mqcno, $conn, $comp_code,$reason);
if ($comp_code !== MQSERIES_MQCC_OK) {
printf("Connx CompCode:%d Reason:%d Text:%s<br>\n", $comp_code, $reason, $reason);
exit;
}
$mqods = array('ObjectName'=>'MYPUTQUEUE', 'ObjectType'=>MQOT_Q, 'ObjectQMgrName'=>'MYQUEUEMANAGER');
mqseries_open($conn, $mqods,
MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT,
$obj, $comp_code,$reason);
THis results in $reason being populated with 2044, which translates to MQRC_OD_ERROR, or in English: 'On the MQOPEN or MQPUT1 call, the object descriptor MQOD is not valid'.
So the question is, what's wrong with my MQOD?
Update #1: At this point this is not resolved. I rebuilt the project from the ground up to resolve any issues at build time. I am still stuck on MQOPEN returning 2044. The samples still run flawlessly from CLI, so this is definitely tied to the installation of the PECL extension. If there's anyone out there who has successfully installed and are running PHP against MQ in a fairly recent 64-bit PHP5 environment please let me know...
Update #2: MQPUT1 works flawlessly with the problem that I can't receive my response. At this point, it's just MQOPEN that doesn't work. Question is; what is causing MQOPEN to return 2044 when MQPUT1 works, which I understand includes MQOPEN?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
cmqch 文件中的 MQOD 如下所示:
我想知道模块是否填充默认值并允许您使用哈希值覆盖。如果是这样,“DeviceName”真的是正确的密钥吗?我认为它会匹配 WMQ 字段名称或常量。
更新:根据提供的链接中的示例,哈希键确实与 cmqc.h 中的字段名称匹配。
更新 #2 回复评论: cmqc.h 中定义的对象类型是:
我对 PHP、Perl 和大多数其他类似工作的理解是,它们是 C API 上的一个非常薄的包装器。 Perl 直接从 cmqc.h 和其他 C 包含文件生成大部分代码,因此所有字段名称和默认值与这些包含文件完全匹配。该模块似乎采用了类似的方法,我希望在需要时使用定义的名称和字段默认值。
我在想类似的事情:
更新 #3 回应其他评论:
Q Mgr 将接受任何版本的 MQOD,但会回退到该功能级别。如果您使用 v1,您可以测试它是否有效。如果您想使用更高版本的 MQOD,则需要将其他字段添加到哈希中。
2009 年是“连接中断”。本质上,QMgr 不喜欢某些东西并终止了您的连接。通常,该返回代码的有意义的错误消息位于
/var/mqm/qmgrs//errors/AMQEER01.LOG
中。The MQOD in the cmqch file looks like this:
I'm wondering if the module fills in the defaults and is letting you override then with the hash. If so, is 'DeviceName' really the right key? I would think it would match the WMQ field name or constant.
Update: Per the example at the link provided, the hash key does indeed match the field name from the cmqc.h.
Update #2 respond to comment: Object types as defined in cmqc.h are:
My understanding of the PHP, Perl and most other similar efforts is that they are a very thin wrapper over the C API. The Perl one simply generates most of the code directly from the cmqc.h and other C include files and therefore all the field names and defaults exactly match those include files. This module appears to have taken a similar approach and I would expect to use the defined names and field defaults where needed.
I'm thinking something like:
Update #3 respond to additional comments:
The Q Mgr will accept any version of the MQOD but will fall back to that level of functionality. If you use v1 you can test out that it works. If you want to use later versions of the MQOD then you will need to add the additional fields to the hash.
The 2009 is "Connection Broken." Essentially the QMgr didn't like something and terminated your connection. Usually the meaningful error messages for that return code are in
/var/mqm/qmgrs/<qmgrname>/errors/AMQEER01.LOG
.