Get RFH2 usr area name-value pairs from MQ queue u

2019-09-14 11:55发布

问题:

Using Java, I want to build a MQ message that has MQMD,RFH2 usr area (with few name-value pairs). I am able to connect to Qmgr and able to read a message from one queue. I want to retrieve all header values (MQMD,RFH2 usr etc) and build one such message based on the retrieved message Can anyone please help me out in this ?

FYI: I am doing a load testing using Loadrunner tool that puts loads of messages on inbound queue and they will be processed and will be sent to outbound queue. And the tool will read the current queue depth of the outbound queue to check the total processing time.

Any suggestion are welcome

Images : MQ Message headers Image

Unsupported Version at MQRFH2

回答1:

About handling the MQ headers using the Java classes for MQ you should read this:

https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q030880_.htm

To solve your requirement I think it is enough to use the MQMD. What I'd do is recording the PutTime and the MsgId of the input message from the MQMD, and the put time of the corresponding output message. (I hope the CorrelId is set to the input MsgId by your application for the response messages.) By calculating the elapsed time between the put times you get the time the message spent in the queue and the processing application.



回答2:

MQRFH2 header can be thought of as a state of mind. You can have message properties with or without an MQRFH2 header.

There is a queue attribute called PROPCTL. You can read about it here.

From your Java code, just do:

MQMessage msg = new MQMessage();
msg.setStringProperty("propName", "propValue");

or if you want to get really fancy, then use the MQRFH2 class.

MQMessage msg = new MQMessage();
MQRFH2 rfh2 = new MQRFH2();
rfh2.setFolderStrings(new String[]{"<d1>First</d1>", "<d2>Second</d2>", "<d3>Third</d3>"});
MQHeaderList putList = new MQHeaderList();
putList.add(rfh2);
msg.format = putList.updateHeaderChaining(CMQC.MQFMT_RF_HEADER_2);

Personally, the first example is far easier and cleaner but hey, that's what I prefer.