0

You want to get a list of the queues for a specific queue manager. I seem to understand how to do this, but when I try, I get an error.

Traceback (most recent call last): File "D:/project/Work-Project/queue list.py", line 23, in response = pcf.MQCMD_INQUIRE_Q(args) File "C:\Users\ShevcovAA\AppData\Local\Programs\Python\Python37\lib\site-packages\pymqi_init_.py", line 2769, in call message = self._pcf.reply_queue.get(None, get_md, get_opts) File "C:\Users\ShevcovAA\AppData\Local\Programs\Python\Python37\lib\site-packages\pymqi_init.py", line 2021, in get raise MQMIError(rv[-2], rv[-1], message=rv[0], original_length=rv[-3]) pymqi.MQMIError: MQI Error. Comp: 2, Reason 2033: FAILED: MQRC_NO_MSG_AVAILABLE

My Code:

import logging
import re
import pymqi

logging.basicConfig(level=logging.INFO)

queue_manager = 'QM1'
channel = 'DEV.APP.SVRCONN'
host = '127.0.0.1'
port = '1414'
conn_info = '%s(%s)' % (host, port)

prefix = "*"
queue_type = pymqi.CMQC.MQQT_LOCAL

args = {pymqi.CMQC.MQCA_Q_NAME: prefix,
        pymqi.CMQC.MQIA_Q_TYPE: queue_type}

qmgr = pymqi.connect(queue_manager, channel, conn_info)
pcf = pymqi.PCFExecute(qmgr)

response = pcf.MQCMD_INQUIRE_Q(args)

for queue_info in response:
    queue_name = queue_info[pymqi.CMQC.MQCA_Q_NAME]
    if (re.match('^SYSTEM', queue_name) or re.match('^AMQ', queue_name) or re.match('^MQ', queue_name)):
        pass
    else:
        q = pymqi.Queue(qmgr, queue_name)
        print(queue_name.strip() + ':' + 'Queue  depth:', q.inquire(pymqi.CMQC.MQIA_CURRENT_Q_DEPTH))
        q.close()

qmgr.disconnect()
shevaa
  • 17
  • 1
  • 5
  • Getting no messages back from the command server is usually a sign that it didn't like your command message for some reason (often authority). Check what is on the DLQ, and if you don't have a DLQ defined, set one up so that the command server can send it's disliked message there. There may also be something in the AMQERR01.LOG, but I don't remember for sure whether the command server writes something there or not. – Morag Hughson Mar 22 '21 at 08:43
  • @MoragHughson I don't know. How it example "https://dsuch.github.io/pymqi/examples.html" name_example: "How to display queues". Shows the queues of which, as it were, I do not have. Output: `INFO:root:Found queue `b'SYSTEM.CLUSTER.TRANSMIT.MODEL.QUEUE ` – shevaa Mar 22 '21 at 08:51
  • Are you saying your code works if you change the prefix and the queue_type? – Morag Hughson Mar 22 '21 at 10:25
  • @morag-hughson Yes, if I do not write `prefix = "SYSTEM.*"`. There is no error in this case – shevaa Mar 22 '21 at 10:56
  • I notice that you are using double quotes whereas the example you refer to is using single quotes. In your previous comment you say that using `prefix = "SYSTEM.*"` with the double quotes does work. Are you certain you used double quotes in that case? I still think this would be easier to diagnose if you could set up a DLQ on your queue manager and see if the command server is rejecting the command by looking what is written there. We are currently just guessing. – Morag Hughson Mar 23 '21 at 02:10

2 Answers2

3

v1.12.0 pymqi uses different logic to get PCF response messages from the response queue.

By default, a timeout of 5 seconds is used to wait for a response. As a result, if you have a lot of queues or your QM is under heavy load, this may not be enough.

To fix this, you can increase this interval using the response_wait_interval parameter of the PCFExecute constructor.

pcf = pymqi.PCFExecute(qmgr, response_wait_interval=30000) # 30 seconds

v1.11.0 does not have this parameter and uses default interval of 30 seconds.

And avoid querying each queue for depth, just query MQIA_CURRENT_Q_DEPTH attribute.

In new notation, supported in v1.12+, it will be something like:

    attrs = []  # type: List[pymqi.MQOpts]
    attrs.append(pymqi.CFST(Parameter=pymqi.CMQC.MQCA_Q_NAME,
                            String=pymqi.ensure_bytes(prefix)))
    attrs.append(pymqi.CFIN(Parameter=pymqi.CMQC.MQIA_Q_TYPE,
                            Value=queue_type))
    attrs.append(pymqi.CFIL(Parameter=pymqi.CMQCFC.MQIACF_Q_ATTRS,
                            Values=[pymqi.CMQC.MQIA_CURRENT_Q_DEPTH]))

    object_filters = []
#        object_filters.append(
#            pymqi.CFIF(Parameter=pymqi.CMQC.MQIA_CURRENT_Q_DEPTH,
#                       Operator=pymqi.CMQCFC.MQCFOP_GREATER,
#                       FilterValue=0))

    response = pcf.MQCMD_INQUIRE_Q(attrs, object_filters)

    for queue_info in response:
        queue_name = queue_info[pymqi.CMQC.MQCA_Q_NAME]
        queue_depth = queue_info[pymqi.CMQC.MQIA_CURRENT_Q_DEPTH]
        print('{}: {} message(s)'.format(queue_name.strip().decode(), queue_depth))
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Seyf
  • 305
  • 2
  • 10
0

Solved this error by simply installing the version below. That is, Meln had PyMQi 1.12.0, and now it is PyMQI 1.11.0

My Code:

import pymqi
import date_conn

qmgr = pymqi.connect(date_conn.queue_manager, date_conn.channel, date_conn.conn_info)
pcf = pymqi.PCFExecute(qmgr)

c = 0
attrs = {
        pymqi.CMQC.MQCA_Q_NAME :'*'
    }
result = pcf.MQCMD_INQUIRE_Q(attrs)

for queue_info in result:
        queue_name = queue_info[pymqi.CMQC.MQCA_Q_NAME]
        print(queue_name)
        c+=1

print(c)
qmgr.disconnect()
shevaa
  • 17
  • 1
  • 5