pymqi - 2009 - 失败:MQRC_CONNECTION_BROKEN

问题描述 投票:0回答:1

我正在本地计算机上运行下面的简单 python MQ put/get 程序,该程序连接到在远程计算机“qmgr.test.com”上运行的 qmgrs 列表。

我收到 MQRC 2009 错误。

MQ Error for QMGR1: 2009 - FAILED: MQRC_CONNECTION_BROKEN

MQ Error for QMGR2: 2009 - FAILED: MQRC_CONNECTION_BROKEN

  • 我的本地机器和 mq 主机之间的连接良好。(telnet 到 mq 主机和端口成功)
  • QMGR1 和 QMGR2 运行良好。
  • 我能够通过“amqsputc”命令将/获取消息发送到同一个 来自我本地的 qmgrs 和队列。
  • MQ 连接详细信息完好无损,我使用 print 语句进行了验证 代码之间。

什么可能导致 MQRC 2009 错误?

import pymqi
import time
import logging

# Configuration details for IBM MQ

queue_managers = [
    {
        'queue_manager': 'QMGR1',
        'channel': 'QMGR1.SVRCONN',
        'queue_name': 'QMGR1.QUEUE',
        'host': 'qmgr.test.com',
        'port': '1441',
        'user': 'mquser',
        'password': '******'
    },
    {
        'queue_manager': 'QMGR2',
        'channel': 'QMGR2.SVRCONN',
        'queue_name': 'QMGR2.QUEUE',
        'host': 'qmgr.test.com',
        'port': '1441',
        'user': 'mquser',
        'password': '******'
    },
]
logging.basicConfig(filename='mq_health_check.log',level=logging.INFO)

def check_queue_manager_health(queue_manager_info, message):
    qmgr = None
    try:
        # Connection info
        conn_info = f"{queue_manager_info['host']}({queue_manager_info['port']})"

        qmgr = pymqi.connect(queue_manager_info['queue_manager'],queue_manager_info['channel'],conn_info,queue_manager_info['user'],queue_manager_info['password'])
        
        # open the queue
        queue = pymqi.Queue(qmgr, queue_manager_info['queue_name'])

        # Send the message
        queue.put(message)
        logging.info(f"Message sent to {queue_manager_info['queue_manager']} on {queue_manager_info['queue_name']}.")

        # Retrieve the message 
        received_message = queue.get()

        # check queue depth
        queue_depth = queue.inquire(pymqi.CMQC.MQIA_CURRENT_Q_DEPTH)
        logging.info(f"Queue Depth for {queue_manager_info['queue_manager']} on {queue_manager_info['queue_name']}: {queue_depth}")

        queue.close()

    except pymqi.MQMIError as e:
        print(f"MQ Error for {queue_manager_info['queue_manager']}: {e.reason} - {e.errorAsString()}")

    except Exception as e:
        print(f"General Error for {queue_manager_info['queue_manager']}: {e.errorAsString()}")
    
    finally:
        if qmgr:
            qmgr.disconnect()

if __name__ == "__main__":
    # Message
    message = "Test Message for monitoring"
    # Send the message to each queue manager
    for manager in queue_managers:
        check_queue_manager_health(manager, message)

使用 mq 客户端的错误日志更新我的问题-

----- amqxufnx.c : 1446 ------------------------------------------ ---------------- 10/16/24 15:58:21 - 进程(15507.1)程序(Python) 主机(AB89548)安装(MQNI93L22121400D) VRMF(9.3.1.0) 时间(2024-10-16T20:58:21.725Z) ArithInsert1(24948) ArithInsert2(2) CommentInsert1(/opt/homebrew/lib64/libmqe_r.dylib) CommentInsert2(没有这样的文件或目录) 评论插入3(64) AMQ6174I:无法打开错误消息 ID 0x6174 的目录,插入:24948、2、/opt/homebrew/lib64/libmqe_r.dylib,否 这样的文件或目录和 64. 在不同的目录上发出“mqrc AMQ6174” 消息描述系统。 ----- amqxufnx.c:1446 ---------------------------------------- ---------------

python ibm-mq pymqi
1个回答
0
投票

我没有检查MQ客户端错误日志。我必须设置动态库路径才能运行我的 python 程序。

导出 DYLD_LIBRARY_PATH=/opt/mqm/lib64

现在一切都好!

© www.soinside.com 2019 - 2024. All rights reserved.