Comment 2 for bug 754999

Revision history for this message
Dariusz Suchojad (dsuch) wrote :

Alright Rik, it's all ready in the lp:~pymqi-dev/pymqi/string-filter branch! Your code should now read:

<code>
pcfQmgr=queueManager.getConnectedPcfQueueManager()
attrs = {MQCA_Q_NAME :'*', MQIA_Q_TYPE : MQQT_ALIAS, MQIACF_Q_ATTRS : MQCA_Q_NAME}
f1 = pymqi.Filter(CMQC.MQCA_BASE_Q_NAME).equal('QL.BANANAS')
res = pcfQmgr.MQCMD_INQUIRE_Q(attrs, [f1])
</code>

The idea is that there's this new pymqi.Filter class which wraps all the gory inner details of how PCF/MQAI filters work. Please have a look at pymqi.FilterOperator.operator_mapping dictionary for more information on what operators are there.

Note that there can be multiple filters, they're all AND-combined, just like below:

<code>
import pymqi, CMQC, CMQCFC

queue_manager = 'QM01'
channel = 'SVRCONN.1'
host = '192.168.1.139'
port = '1434'
conn_info = '%s(%s)' % (host, port)

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

attrs = {CMQC.MQCA_Q_NAME :'*', CMQC.MQIA_Q_TYPE : CMQC.MQQT_LOCAL, CMQCFC.MQIACF_Q_ATTRS : CMQC.MQCA_Q_NAME}

f1 = pymqi.Filter(CMQC.MQCA_Q_DESC).like('WebSphere MQ Selection*')
f2 = pymqi.Filter(CMQC.MQIA_CURRENT_Q_DEPTH).greater(2)

res = pcf.MQCMD_INQUIRE_Q(attrs, [f1, f2])
print(res)
</code>