0

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

fvu
  • 32,488
  • 6
  • 61
  • 79
chaitu k
  • 23
  • 2
  • 6
  • Have a look [here](http://stackoverflow.com/questions/11002772/java-convert-bytemessage-to-string), it shows how to convert a ByteMessage back to a String (but read the accept answer completely, you risk charset issues). – fvu Sep 23 '13 at 11:54

1 Answers1

0

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";
nitgeek
  • 1,250
  • 12
  • 20
  • thanks,what is the difference if i write message as string and setting format to MQSTR. – chaitu k Sep 23 '13 at 12:30
  • @chaituk I believe, when you use writestring, you will be able to read message as string in recieving application (using readstring function). But, sometimes a few applications can't handle MQRFH2 format messages and asks the sending application to explicitly set the MQ format as MQSTR.ALthough, if you don't set anything, then by default its considered as MQSTR only. – nitgeek Sep 23 '13 at 12:45