0
votes

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

1
Have a look here, it shows how to convert a ByteMessage back to a String (but read the accept answer completely, you risk charset issues).fvu

1 Answers

0
votes

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";