0

I am attempting to port some old java code to python.

I am using pymqi to connect to a queue manager and query for all messageflow statistics topics using the topic string: $SYS/Broker/+/StatisticsAccounting/Archive/#

When using the existing java program messages are read from the topic without issue. When using the new python code it is able to connect and query the topic without issue but always gives the message

Reason 2033: FAILED: MQRC_NO_MSG_AVAILABLE

Stats messages are published by the broker for each messageflow every 10 minutes, and I have left the new code running for over 30minutes, never having received a message.

I've also tried setting

get_opts['WaitInterval'] = pymqi.CMQC.MQWI_UNLIMITED 

and sitting around for 20minutes rather than using a loop, but no luck.

Is there any IIB server config that might be impacting the messages that I am able to see, or are there other options I should be using within the client?

import pymqi

queue_manager = 'MYQM'
channel = 'MYAPP.SVRCONN'
host = 'MYHOST'
port = 'MYPORT'
topic_string = '$SYS/Broker/+/StatisticsAccounting/Archive/#'
conn_info = '%s(%s)' % (host, port)
user = ""
password = ""

qmgr = pymqi.QueueManager(None)
qmgr.connect_tcp_client(queue_manager, pymqi.CD(), channel, conn_info, user, password)
sub_desc = pymqi.SD()
sub_desc['Options'] = pymqi.CMQC.MQSO_CREATE + pymqi.CMQC.MQSO_RESUME + pymqi.CMQC.MQSO_MANAGED
sub_desc.set_vs('SubName', 'apptest')
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_WAIT)
get_opts['WaitInterval'] = 10000

md = pymqi.md()
keep_running = True
while keep_running:
    try:
        # Reset the MsgId, CorrelId & GroupId so that we can reuse
        # the same 'md' object again.
        md.MsgId = pymqi.CMQC.MQMI_NONE
        md.CorrelId = pymqi.CMQC.MQCI_NONE
        md.GroupId = pymqi.CMQC.MQGI_NONE

        message = sub.get(None, md, get_opts)
        print('Have message from Queue')
        print(message)

    except pymqi.MQMIError as e:
        if e.comp == pymqi.CMQC.MQCC_FAILED and e.reason == pymqi.CMQC.MQRC_NO_MSG_AVAILABLE:
            print("no message?")
            print(e)
            pass
        else:
            # Some other error condition.
            raise

    except (UnicodeDecodeError, ValueError)  as e:
        print('Message is not valid json')
        print(e)
        print(message)
        continue

    except KeyboardInterrupt:
        print('Have received a keyboard interrupt')
        keep_running = False


sub.close(sub_close_options=0,close_sub_queue=True)
qmgr.disconnect()


smc87
  • 35
  • 5
  • Please can you issue the following command after your subscription has been running for 30 minutes (and while it is still running) and add the responses to the question description above. DISPLAY TPSTATUS('$SYS/Broker/+/StatisticsAccounting/Archive/#') TYPE(SUB) ALL This command will show the number of messages (NUMMSGS field) sent to the subscriber, and show whether the problem is with retrieving the messages or whether they are not even being delivered to the subscriber. – Morag Hughson Oct 29 '20 at 03:34
  • Hi, I presume you want me to issue this on the broker side, rather than from the python script? – smc87 Oct 29 '20 at 08:53
  • That is a MQSC command to run against the queue manager. – JoshMc Oct 29 '20 at 09:11
  • AMQ8754: Display topic status details. TOPICSTR($SYS/Broker/BROKERNAME/StatisticsAccounting/Archive/SUPC_Internal/flowName) SUBID(414D5120564D51494E535431202020205F6F4490287598D0) SUBUSER(itmagent) RESMDATE(2020-10-19) RESMTIME(09:45:24) LMSGDATE(2020-10-29) LMSGTIME(12:04:18) ACTCONN(000000000000000000000000000000000000000000000000) DURABLE(NO) SUBTYPE(API) MCASTREL( , ) NUMMSGS(2273624) – smc87 Oct 29 '20 at 12:36
  • AMQ8754: Display topic status details. TOPICSTR($SYS/Broker/BROKERNAME/StatisticsAccounting/Archive/MDAT/flowName) SUBID(414D5120564D51494E535431202020205F93801F22A56B09) SUBUSER(mqtest) RESMDATE(2020-10-29) RESMTIME(11:23:30) LMSGDATE( ) LMSGTIME( ) ACTCONN(414D5143564D51494E535431202020205F93801F22A56B06) DURABLE(NO) SUBTYPE(API) MCASTREL( , ) NUMMSGS(0) – smc87 Oct 29 '20 at 12:36
  • It seems there are messages on some but not all – smc87 Oct 29 '20 at 12:37
  • Indeed it does seem that messages are being produced on some of the topics that should match your subscription. Can you also try this MQSC command:- DISPLAY SBSTATUS('apptest') ALL which should show only what is being sent to your specific subscription. – Morag Hughson Oct 30 '20 at 03:02

0 Answers0