0
votes

I recently inherited a testing framework using PYMQI to put a message on IBM Websphere Queue. I fixed most of the code i need by going through this link

https://dsuch.github.io/pymqi/examples.html#how-to-correlate-request-and-response-messages-using-correlationid

The only pending issue is the format of correlation ID. I tried quite a few options but MQ is converting the correlation ID Into byte array (seems IBM MQ default setting) before throwing it on the Q. All my downstream systems are looking for a HEX value and is breaking.

I am stuck on this for a few days now. Is there a way to force the correlation ID in message properties?.

Please let me know

Regards Aravind

@JoshMc thanks a lot for the reply. It is proprietary code so little difficult to paste whole thing however here is the relevant piece. Downstream system is looking at this JMS Correlation ID to increment and put back in the queue. When i am sending this through below code it hits queue gets converted to byte array however downstream system read validation fails. I want this to hit the queue as a HEX value as in it should be the exact value i pass and not byte array.

queue = self._open_write_queue(queue_name)

put_mqmd = pymqi.md()
put_mqmd.Format = CMQC.MQFMT_STRING
CCSID = 1202

 put_opts = pymqi.pmo()
# Set the MsgType to request.
# put_mqmd["MsgType"] = CMQC.MQMT_REQUEST
put_mqmd["MsgId"] = '00002Y0001T1'
put_mqmd["CorrelId"] = '00002Y0001T1'

 put_opts = pymqi.PMO(Options=CMQC.MQPMO_NO_SYNCPOINT +
                                         CMQC.MQPMO_FAIL_IF_QUIESCING + CMQC.MQRO_PASS_CORREL_ID)
            queue.put(message, put_mqmd, put_opts)

when I put a message through to the queue, it is getting posted successfully, but does not get processed by the downstream system:

In the screenshot below the first message in the queue was posted using app JMSToolBox- which has the correlation as expected by the downstream system. The second message was posted using pymqi - which has the correlation-id displayed ID:'hex format'. Also there is JMSDestination displayed as null.

In the screenshot above the first message in the queue was posted using app JMSToolBox- which has the correlationId as expected by the downstream systems. The second message was posted using robot framework/pymqi - which has the correlation-id displayed ID:30303..... Also please note that the JMSDestination is displayed as null for the second message.(For the first message posted manually has the as 'JMSDestination: queue:///QueueName'

Now i have two issues - CorrelationId not coming up as i expect and the JMSDestination:null. I'm not sure how I can set the destination using pymqi library(or is this set at Q-Manager level) Any help is much appreciated.

Screenshot of message sent by JMSToolBox: enter image description here

Screenshot of message sent using robotframework-pymqi: enter image description here

The only difference I find in the two messages now is the JMSDestination:Null in the JMSHeader for the message sent using Pymqi. I also tried changing the PROPCTL setting for the queue- but did not help.

Is there a I can send the java properties using pymqi?

1
A correlationID IS a byte value. Most apps display this as the HEX values of those bytes. Can you put since minimal sample that produces the issue you are facing?JoshMc
Please check the update for relevant code pieces. Thanks again for helping meAravind R
Can you show it with a realistic value being passed?JoshMc
Please add screenshot with your messages from MQ Explorer. Nobody have your "client" , nobody know how it works and nobody know how it parses IDs.Seyf
ibm.com/support/knowledgecenter/SSEQTP_9.0.5/… MQRFH2 jms.Dst (JMSDestination) This field is present in IBM MQ format JMS messages that include the MQRFH2 header. The jms.Dst field contains a serialized representation (a IBM MQ URI) of the send-to JMS destination that was set when the application issued send for the message. IBM MQ does not use the forward routing path, but the send-to destination might be in a remote service integration bus that can use the forward routing path.Seyf

1 Answers

1
votes

As the comments indicate, the correlation id needs to be a byte array padded out to 24 bytes or 48 hexadecimals. So

Python 2 & 3 compatible way

put_mqmd["CorrelId"] = 'Aravind'.ljust(24).encode('utf-8')

Python 3 only way

put_mqmd["CorrelId"] = bytes('Aravind'.ljust(24), 'utf-8')

but the easiest way is to let the underlying client generate it for you by passing in CMQC.MQPMO_NEW_CORREL_ID. I can't tell you where in your code, because you haven't shown that bit, but there are samples in the pymqi documentation.