使用JMS客户端处理MQ ByteMessage [英] Processing MQ ByteMessage using JMS client
问题描述
我正在使用IBM MQ和Java将消息作为字节写入队列.我在这里遇到的问题是,正在从JMS客户端会话中读取此消息,这是预期的格式,我得到的是"BytesMessage"而不是MQSTR格式的消息.
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.
将消息写入队列时必须设置哪些属性,以便JMS客户端将该消息作为文本而不是字节使用?
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());
此致
Chaitu
推荐答案
好吧,如果您的消息将仅是文本格式,那么写为Bytes的目的是什么.
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);
此外,您可以将邮件的格式"属性设置为任何有效格式(MQRFH2,MQSTR等),例如:
Also, you can set the "format" property of your message to any valid format(MQRFH2, MQSTR etc) like:
mqm.format="MQSTR";
这篇关于使用JMS客户端处理MQ ByteMessage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!