java 队列取指定值,使用Java从MQ队列中获取RFH2 usr区域名称/值对

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值