pymqi 连接ibm mq 的topic获得预订消息
import logging
import pymqi
logging.basicConfig(level=logging.INFO)
queue_manager = 'QM1'
channel = 'DEV.APP.SVRCONN'
host = '127.0.0.1'
port = '1414'
topic_string = '/currency/rate/EUR/USD'
msg = '1.3961'
conn_info = '%s(%s)' % (host, port)
qmgr = pymqi.QueueManager(None)
qmgr.connect_tcp_client(queue_manager, pymqi.CD(), channel, conn_info)
sub_desc = pymqi.SD()
sub_desc['Options'] = pymqi.CMQC.MQSO_CREATE + pymqi.CMQC.MQSO_RESUME + \
pymqi.CMQC.MQSO_DURABLE + pymqi.CMQC.MQSO_MANAGED
sub_desc.set_vs('SubName', 'MySub')
sub_desc.set_vs('ObjectString', topic_string)
sub = pymqi.Subscription(qmgr)
sub.sub(sub_desc=sub_desc)
get_opts = pymqi.GMO(
Options=pymqi.CMQC.MQGMO_NO_SYNCPOINT + pymqi.CMQC.MQGMO_FAIL_IF_QUIESCING + pymqi.CMQC.MQGMO_WAIT)
get_opts['WaitInterval'] = 15000
data = sub.get(None, pymqi.md(), get_opts)
logging.info('Here's the received data: [%s]' % data)
sub.close(sub_close_options=pymqi.CMQC.MQCO_KEEP_SUB, close_sub_queue=True)
qmgr.disconnect()
代码是从api文档截取的,使用后一直报MQI Error. Comp: 2, Reason 2033: FAILED: MQRC_NO_MSG_AVAILABLE,但是我的主题是有消息的。
网上没有别人连接topic的案例
我希望可以获得主题中预订的信息