ibm mq在java工程中使用bytesmessage,使用JMS客户端处理MQ ByteMessage

本文介绍如何使用Java通过IBM MQ将文本消息写入队列,遇到的挑战是接收端期望MQSTR格式而非BytesMessage。解决方案包括使用MQMessage的writeString()方法和设置message格式为MQSTR。
摘要由CSDN通过智能技术生成

I am using IBM MQ and Java to write a message as Bytes on to the queue. Problem here i am getting here is while reading this message from JMS client offcourse that is expected format,i am getting as "BytesMessage" instead of message in MQSTR format.

What properties i have to set while writing the message on to the queue ,so JMS client consume that message as Text instead of Byte?

Do i need to chnage any of the below properties or anything else?

openOptions =MQC.MQOO_OUTPUT

putOptions=MQC.MQPMO_SYNCPOINT

Below is the sample producer code,Here i am not mentioning entire code.

String message="text";

final MQMessage mqm = new MQMessage();

mqm.write(message.getBytes());

Regards,

Chaitu

解决方案

Well, if your message is going to be of text format only, then what's the point of writing as Bytes.

Instead, you can use other functions like:

String message="text";

MQMessage mqm = new MQMessage();

mqm.writeString(message);

Also, you can set the "format" property of your message to any valid format(MQRFH2, MQSTR etc) like:

mqm.format="MQSTR";

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值