You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

添加pymqi.PCFExecute后触发IBM MQ 2035未授权错误的解决方案咨询

解决IBM MQ 2035(MQRC_NOT_AUTHORIZED)权限错误

我编写了一段简单的Python代码用于向IBM MQ发送消息,原本代码运行正常,但添加pcf = pymqi.PCFExecute(qmgr)语句后,抛出错误“Error: MQI Error. Comp: 2, Reason 2035: FAILED: MQRC_NOT_AUTHORIZED”。代码如下:

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}')

解决方案

  • 为用户授予PCF操作权限
    PCF操作涉及队列管理器的配置查询、修改等,需要比普通消息收发更高的权限。使用setmqaut命令给app用户添加必要权限:

    # 授予队列管理器的查询、显示、修改权限(根据实际需求调整)
    setmqaut -m QM1 -t qmgr -p app +inq +dsp +chg
    
  • 检查通道MCAUSER配置
    确认DEV.APP.SVRCONN通道的MCAUSER是否被强制设置为其他无权限用户。通过runmqsc命令查看:

    runmqsc QM1
    DIS CHANNEL(DEV.APP.SVRCONN) MCAUSER
    

    若MCAUSER不是app,要么给该用户添加PCF权限,要么修改通道配置将MCAUSER设为app(需符合安全规范)。

  • 验证用户有效性
    确保app用户在MQ所在系统(或认证源如LDAP)中存在,且密码qwerty正确有效。

  • 移除不必要的PCF初始化
    如果代码仅需发送消息,不需要执行PCF操作,直接删除pcf = pymqi.PCFExecute(qmgr)语句即可恢复正常。

内容的提问来源于stack exchange,提问作者K Ashish

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 06:17:16