0

I want to see Message ID (MsgId) of a MQ message while doing a MQ GET call through Py-MQI. Below is my code but , I am not able to see the Message ID.

import pymqi

queue_manager = 'QM01'
channel = 'DEV.SRVCONN'
host = 'mqtest'
port = '1419'
queue_name = 'POC.XFER'
conn_info = '%s(%s)' %(host, port)

# Message Descriptor
md = pymqi.MD()

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

queue = pymqi.Queue(qmgr, queue_name)
message = queue.get(None, md)
print(str(message.decode()))
       
queue.close()     

qmgr.disconnect()
CRP
  • 9
  • 2
  • I think it would be in the `md` (message descriptor). – JoshMc Feb 24 '22 at 17:55
  • could you please elaborate? I tried with print(md['MsgId']) but its returning me empty string. Again I need to see the value of MsgId associated with that message in MQ. – CRP Feb 24 '22 at 17:58
  • Check for sample pymqi apps that demonstrate request / reply, these should show how to pull the message id and CorrelId. – JoshMc Feb 24 '22 at 18:01
  • I am able to see something after doing "md.MsgId" but the output is non-readable. output -----> AMQ QMHAT01 w\xc9\x08b\x0b\rp! Actual message id is "414D5120514D4841543031202020202077C908620C0D7021" – CRP Feb 24 '22 at 19:41
  • It is a binary value that you would need to display as hex. If you display as ASCII it will print what it can, 41 is hex for ascii A, 4D is M, etc. If not a ascii value it prints the hex value, ex \xc9 is hex C9. – JoshMc Feb 24 '22 at 20:04
  • Maybe this will help you https://stackoverflow.com/questions/6624453/whats-the-correct-way-to-convert-bytes-to-a-hex-string-in-python-3 – JoshMc Feb 24 '22 at 20:10
  • can you please let me know how to convert that bytes to hex? – CRP Feb 24 '22 at 20:11
  • With above URL got it. Thanks. – CRP Feb 24 '22 at 20:14
  • Can you self answer with your working code and update and close your pymqi issue. – JoshMc Feb 25 '22 at 00:30
  • You should post a self answer here with your updated code. – JoshMc Feb 25 '22 at 14:40

0 Answers0