IBM MQ Issue - Error: MQI Error. Comp: 2, Reason 2035: FAILED: MQRC_NOT_AUTHORIZED

107 Views Asked by At

I am writing simple python code to put message in the IBM MQ. The code works fine, except when i add 'pcf = pymqi.PCFExecute(qmgr)' line it throws an error 'Error: MQI Error. Comp: 2, Reason 2035: FAILED: MQRC_NOT_AUTHORIZED'

Suggest the solution for the same.

import pymqi

queue_manager = 'QM1'
channel = 'DEV.APP.SVRCONN'
host = '127.0.0.1'
port = '1414'
queue_name = 'DEV.QUEUE.1'
message = 'Hello from Python!'
conn_info = f'{host}({port})'
user = 'app'
password = 'qwerty'

try:
    # Establish connection to the queue manager
    qmgr = pymqi.connect(queue_manager, channel, conn_info, user, password)

    # Create a PCFExecute object
    pcf = pymqi.PCFExecute(qmgr)

    # Open the queue
    queue = pymqi.Queue(qmgr, queue_name)

    # Put a message to the queue
    queue.put(message)

    # Close the queue
    queue.close()

except pymqi.MQMIError as e:
    print(f'Error: {e}')

1

There are 1 best solutions below

0
K Ashish On

Issue solved after providing the right permission to the user. These permissions are not recommended for prod environment.

SET AUTHREC OBJTYPE(QMGR) PRINCIPAL('app') AUTHADD(ALL)
SET AUTHREC OBJTYPE(QUEUE) PROFILE('**') PRINCIPAL('app') AUTHADD(ALL)
SET AUTHREC OBJTYPE(TOPIC) PROFILE('**') PRINCIPAL('app') AUTHADD(ALL)