pythonibm-mqpymqi

pymqi - 2009 - FAILED: MQRC_CONNECTION_BROKEN


I'm running a below simple python MQ put/get program in my local machine that connects to a list of qmgrs running on a remote machine 'qmgr.test.com'.

I'm getting MQRC 2009 error.

MQ Error for QMGR1: 2009 - FAILED: MQRC_CONNECTION_BROKEN

MQ Error for QMGR2: 2009 - FAILED: MQRC_CONNECTION_BROKEN

what could cause MQRC 2009 error?

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)

updating my question with error logs from mq client-

----- amqxufnx.c : 1446 ------------------------------------------------------- 10/16/24 15:58:21 - Process(15507.1) Program(Python)
                    Host(AB89548) Installation(MQNI93L22121400D)
                    VRMF(9.3.1.0)
                    Time(2024-10-16T20:58:21.725Z)
                    ArithInsert1(24948) ArithInsert2(2)
                    CommentInsert1(/opt/homebrew/lib64/libmqe_r.dylib)
                    CommentInsert2(No such file or directory)
                    CommentInsert3(64)
                    AMQ6174I: Failed to open catalog for error message id 0x6174, inserts: 24948, 2, /opt/homebrew/lib64/libmqe_r.dylib, No such file or directory and 64. Issue "mqrc AMQ6174" on a different system for a description of the message.
----- amqxufnx.c : 1446 -------------------------------------------------------

Solution

  • I didn't check the MQ client error logs. I had to set the dynamic library path to get my python program running.

    export DYLD_LIBRARY_PATH=/opt/mqm/lib64

    All good now!