pythonibm-mqtdepymqi

How to connect to IBM MQ in Python with CCDT file, userid and password


I am able to connect to TDE MQ using CCDT file with User id and password in Java. I am unable to do that in Python.

In Python I have set the environment variable for MQCHLLIB and MQCHLTAB, but when I try to connect using pymqi.connect, I am getting MQRC 2538. My code is as below

import pymqi
import os

os.environ['MQCHLLIB']='/root/pythonmq/'
os.environ['MQCHLTAB']='APPTDECH.TAB'

queue_manager = 'QM_APP'
user = "******" 
password = "*****"

qmgr = pymqi.connect(queue_manager, pymqi.CD(),None, user, password )

print('Connected')

qmgr.disconnect()

The exception is :

pymqi.MQMIError: MQI Error. Comp: 2, Reason 2538: FAILED: MQRC_HOST_NOT_AVAILABLE.

Please let me know if anybody know how can I make this happen.


Solution

  • In order to use the CCDT, you have to use the version of pymqi.connect that doesn't specify channel stuff (e.g. pymqi.CD()), e.g.

    qmgr = pymqi.connect(queue_manager)
    

    However, then you don't have any parameters to put the user and password into.

    In short, the Python interface doesn't have all the combinations you need.

    IBM MQ supplied an exit called mqccred which can substitute in the credentials for you, for applications that either can't be changed, or in your case don't have the ability to, pass a user id and password.

    Further Reading