Specify string filter for inquire command

Bug #754999 reported by Dariusz Suchojad
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyMQI
Fix Committed
Medium
Dariusz Suchojad

Bug Description

I have difficulties constructing a string filter. Can you please assist me? Thanks.

I want to do a similar PCF call as in:
<runmqsc>
dis qalias(*) where (targq EQ "QL.BANANAS")
</runmqsc>

For this I will probably need to code something like this:
<code>
pcfQmgr=queueManager.getConnectedPcfQueueManager()
res=pcfQmgr.MQCMD_INQUIRE_Q({MQCA_Q_NAME :'*',
                                                      MQIA_Q_TYPE : MQQT_ALIAS,
                                                      MQIACF_Q_ATTRS : MQCA_Q_NAME,
                                                      MQCFT_STRING_FILTER : MQCA_BASE_Q_NAME MQCFOP_EQUAL "QL.BANANAS"})
</code>

Dariusz Suchojad (dsuch)
summary: - Specify string filter for inquire comm
+ Specify string filter for inquire command
Changed in pymqi:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Dariusz Suchojad (dsuch)
milestone: none → 1.3
Revision history for this message
Dariusz Suchojad (dsuch) wrote :

Hi Rik,

I think I have it all conceptually laid down, so I reckon it should land in the branch in the next several days or so. Will keep you updated as I go!

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>

Changed in pymqi:
status: Confirmed → Fix Committed
Revision history for this message
Rik Baeten (rik-baeten) wrote :

Very nice. Thanks for the implementation!

I will play with it out as soon as I find some time.

An idea that pops in my head as I hear filters are always AND-combined: you cannot OR-combine them. But that's a limitation in PCF itself I guess, that pymqi inherits. On the other hand: an OR-statement can be expressed as a combination of AND and NOT statements. So there is always a way around it. I guess it's too complex to let pymqi do that conversion for you, but it would be neat. It's just and idea, so I'm not requesting to implement it. I wouldn't need it at the moment anyhow.

Revision history for this message
Rik Baeten (rik-baeten) wrote :

I've tested it and it works perfectly. Thanks!

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

Thanks for confirming it Rik! The idea of advanced filters sounds very interesting. I won't be implementing it right now but have opened a bug report regarding it at http://pad.lv/771960

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

I've just released PyMQI 1.3 and the development effort has moved to GitHub - https://github.com/dsuch/pymqi

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.