pythonpython-3.xibm-mqpymqi

How to configure python program connect QUEUE MANAGE?


I'm write a new program, and want to connect to queue manager. how do I configure in python program?


Solution

  • PyMQI allows one to connect to queue managers to issue MQAI and PCF requests.

    Below code establishes a connection, puts a message on a queue and disconnects.

    import pymqi
    
        queue_manager = 'QM01'
        channel = 'SVRCONN.1'
        host = 'host.domain.com'
        port = '1434'
        queue_name = 'TEST.1'
        message = 'Hello from Python!'
        conn_info = '%s(%s)' % (host, port)
    
        qmgr = pymqi.connect(queue_manager, channel, conn_info)
    
        queue = pymqi.Queue(qmgr, queue_name)
        queue.put(message)
        queue.close()
    
        qmgr.disconnect()
    

    More details: https://github.com/dsuch/pymqi