Add support for byte strings in calls to MQAI

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

Bug Description

A follow-up from question #136313 - byte strings should be supported when invoking MQAI from pymqe so that PCF commands such as MQCMD_INQUIRE_CONNECTION actually start working.

Related branches

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

If you have a look at the code I've pushed up to the branch, you'll notice a couple of changes regarding byte string, the end result is that the code returns the expected output, as seen below. Can you please confirm it's all OK for you as well?

import pymqi
from CMQC import *
from CMQCFC import *

cd = pymqi.cd()
cd.ChannelName = 'SVRCONN.1'
cd.ConnectionName = '127.0.0.1(1418)'

cd.ChannelType = MQCHT_CLNTCONN
cd.TransportType = MQXPT_TCP

qmgr = pymqi.QueueManager(None)
qmgr.connectWithOptions('QM01', opts=MQCNO_HANDLE_SHARE_NO_BLOCK, cd=cd)
pcf=pymqi.PCFExecute(qmgr)

conns=pcf.MQCMD_INQUIRE_CONNECTION(
    {MQBACF_GENERIC_CONNECTION_ID: pymqi.ByteString(''),
     MQIACF_CONNECTION_ATTRS:MQIACF_ALL,
     MQIACF_CONN_INFO_TYPE:MQIACF_CONN_INFO_CONN}
)

print(conns)

[{1024L: 2393L, 1025L: 1L, 1L: 7L, 1308L: 0L, 3501L: '', 3506L: '', 3025L: 'mqm ', 1108L: 1L, 1110L: 1111L, 7005L: '', 7006L: 'AMQCQM01 A\xb6\xf7L\x01', 7007L: 'AMQCQM01 A\xb6\xf7L\x01', 7009L: '', 3174L: 'WebSphere MQ Object Authority Manager', 1128L: 0L, 1132L: 0L, 3058L: 'amqzfuma ', 3060L: '', 3061L: '', 3062L: '', 3063L: '', 3064L: ''}, {1024L: 2422L, 1025L: 1L, 1L: 7L, 1308L: 0L, 3501L: '', 3506L: '', 3025L: 'mqm ', 1108L: 256L, 1110L: 1111L, 7005L: '', 7006L: 'AMQCQM01 A\xb6\xf7L\x01\x06', 7007L: 'AMQCQM01 A\xb6\xf7L\x01\x06', 7009L: '', 3174L: 'WebSphere MQ Deferred Message Processor', 1128L: 0L, 1132L: 0L, 3058L: 'amqzdmaa ', 3060L: '', 3061L: '', 3062L: '', 3063L: '', 3064L: ''}, {1024L: 2421L, 1025L: 1L, 1L: 7L, 1308L: 0L, 3501L: '', 3506L: '', 3025L: 'mqm ', 1108L: 256L, 1110L: 1111L, 7005L: '', 7006L: 'AMQCQM01 A\xb6\xf7L\x01\x07', 7007L: 'AMQCQM01 A\xb6\xf7L\x01\x07', 7009L: '', 3174L: 'WebSphere MQ Cluster Repository', 1128L: 1L, 1132L: 0L, 3058L: 'amqrrmfa ', 3060L: '2010-12-02 ', 3061L: '17.07.46', 3062L: '', 3063L: '', 3064L: ''}, {1024L: 2449L, 1025L: 1L, 1L: 7L, 1308L: 0L, 3501L: '', 3506L: '', 3025L: 'mqm ', 1108L: 256L, 1110L: 1111L, 7005L: '', 7006L: 'AMQCQM01 A\xb6\xf7L\x01\r', 7007L: 'AMQCQM01 A\xb6\xf7L\x01\r', 7009L: '', 3174L: 'WebSphere MQ Command Server', 1128L: 0L, 1132L: 0L, 3058L: 'amqpcsea ', 3060L: '', 3061L: '', 3062L: '', 3063L: '', 3064L: ''}, {1024L: 2448L, 1025L: 1L, 1L: 7L, 1308L: 0L, 3501L: '', 3506L: '', 3025L: 'mqm ', 1108L: 256L, 1110L: 1111L, 7005L: '', 7006L: 'AMQCQM01 A\xb6\xf7L\x01\x0e', 7007L: 'AMQCQM01 A\xb6\xf7L\x01\x0e', 7009L: '', 3174L: 'WebSphere MQ Channel Initiator', 1128L: 0L, 1132L: 0L, 3058L: 'runmqchi ', 3060L: '', 3061L: '', 3062L: '', 3063L: '', 3064L: ''}, {1024L: 2678L, 1025L: 70L, 1L: 25L, 1308L: 1L, 3501L: 'SVRCONN.1 ', 3506L: '127.0.0.1 ', 3025L: 'mqm ', 1108L: 320L, 1110L: 1111L, 7005L: '', 7006L: 'AMQCQM01 A\xb6\xf7L\t7', 7007L: 'AMQCQM01 A\xb6\xf7L\t7', 7009L: '', 3174L: '', 1128L: 0L, 1132L: 0L, 3058L: 'python', 3060L: '', 3061L: '', 3062L: '', 3063L: '', 3064L: ''}]

Changed in pymqi:
status: Confirmed → Fix Committed
Revision history for this message
Hannes Wagener (johannes-wagener) wrote :

Excellent! This fixes much! I was just about to spend time to investigate why I cannot query subscriptions with pcf(I even thought about sending a clue with a Bag in a Bag. ;-)

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

Heh, yea, Bag in a Bag is a hidden gem only few have unearthed so far ;-) Seriously though, I'll leave it as is, on one hand I don't know neither what to show when such thing happens and on the other, who said we cannot have a semi-easter egg?

Would be fantastic if you could try byte strings with the subscriptions you mentioned, Hannes. I really haven't had need for it and I guess that explains why I hadn't stumbled upon it any earlier.. I'll add the sample code for checking the subscriptions to the examples if you're willing to contribute it. Ditto for MQCMD_INQUIRE_CONNECTION, by the way.

Revision history for this message
Hannes Wagener (johannes-wagener) wrote :
Download full text (5.2 KiB)

Sure!

<code>
import pymqi
import CMQC, CMQCFC

# Queue manager name
qm_name = "LDB0"
# Listener host and port
listener = "localhost(1414)"
# Channel to transfer data through
channel = "SYSTEM.DEF.SVRCONN"

# Connect to queue manager
qm = pymqi.QueueManager(None)
qm.connectTCPClient(qm_name, pymqi.cd(), channel, listener)

pcf = pymqi.PCFExecute(qm)

topic_dict = pcf.MQCMD_INQUIRE_TOPIC({CMQC.MQCA_TOPIC_NAME : '*'})
print topic_dict

sub_dict = pcf.MQCMD_INQUIRE_SUBSCRIPTION({CMQCFC.MQCACF_SUB_NAME : '*'})
print sub_dict

sub_status_dict = pcf.MQCMD_INQUIRE_SUB_STATUS({CMQCFC.MQCACF_SUB_NAME : '*'})
print sub_status_dict

"""Sample Results:
[{2096L: 'SYSTEM.DURABLE.MODEL.QUEUE ', 2027L: '2010-11-14 ', 196L: 3L, 2097L: 'SYSTEM.NDURABLE.MODEL.QUEUE ', 6L: 0L, 199L: 2L, 2028L: '02.56.45', 2029L: ' ', 2092L: 'SYSTEM.BASE.TOPIC ', 2093L: 'Base topic for resolving attributes ', 2094L: '', 175L: 1L, 208L: 0L, 216L: 2L, 195L: 2L, 181L: 2L, 182L: 2L, 184L: 1L, 185L: 0L, 218L: 0L, 219L: 0L}, {2096L: ' ', 2027L: '2010-11-14 ', 196L: 0L, 2097L: ' ', 6L: -2L, 199L: 2L, 2028L: '02.56.46', 2029L: ' ', 2092L: 'SYSTEM.BROKER.ADMIN.STREAM ', 2093L: 'Admin stream for queued Pub/Sub interface ', 2094L: 'SYSTEM.BROKER.ADMIN.STREAM', 175L: 0L, 208L: 0L, 216L: 1L, 195L: 0L, 181L: 0L, 182L: 0L, 184L: 0L, 185L: -1L, 218L: 1L, 219L: 1L}, {2096L: ' ', 2027L: '2010-11-14 ', 196L: 0L, 2097L: ' ', 6L: -2L, 199L: 2L, 2028L: '02.56.46', 2029L: ' ', 2092L: 'SYSTEM.BROKER.DEFAULT.STREAM ', 2093L: 'Default stream for queued Pub/Sub interface ', 2094L: '', 175L: 0L, 208L: 0L, 216L: 1L, 195L: 0L, 181L: 0L, 182L: 0L, 184L: 0L, 185L: -1L, 218L: 1L, 219L: 1L}, {2096L: ' ', 2027L: '2010-11-14 ', 196L: 0L, 2097L: ' ', 6L: -2L, 199L: 2L, 2028L: '02.56.46', 2029L: ' ', 2092L: 'SYSTEM.BROKER.DEFAULT.SUBPOINT ', 2093L: 'Default RFH2 subscription point for queued Pub/Sub interface ', 2094L: '', 175L: 0L, 208L: 0L, 216L: 1L, 195L: 0L, 181L: 0L, 182L: 0L, 184L: 0L, 185L: -1L, 218L: 1L, 219L: 1L}, {2096L: ' ', 2027L: '2010-11-14 ', 196L: 0L, 2097L: ' ', 6L: -2L, 199L: 2L, 2028L: '02.56.45', 2029L: ' ', 2092L: 'SYSTEM.DEFAULT.TOPIC ', 2093L: ' ', 2094L: '', 175L: 0L, 208L: 0L, 216L: 2L, 195L: 0L, 181L: 0L, 182L: 0L, 184L: 0L, 185L: -1L, 218L: 1L, 219L: 1L}, {2096L: ' ...

Read more...

Revision history for this message
Hannes Wagener (johannes-wagener) wrote :

Oh. By the way. I also have one or two samples for creating MQ objects with PCF(subscriptions, topics) and soon I will have examples for subscribe/publish via pcf.

In addition - one example that I believe would be of benefit is showing howto correlate request with response via the MQMD CorrelId. Should I post them? Or should I just include them in my current pub-sub branch?

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

Tested and works for me (Ubuntu 10.04).

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

Rik - I've merged the code to trunk. Thanks for spotting it and confirming it's OK now.

Hannes - send them in to me. I'll apply them to trunk and publish it all on the website at http://packages.python.org/pymqi/examples.html - cheers again mate!

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

Fixed as of PyMQI 1.2

Changed in pymqi:
milestone: 1.2 → none
status: Fix Committed → Fix Released
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.