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
解决方案
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[]{"First", "Second", "Third"});
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.