I wrote a API EXIT for WebSphere MQ 7 on Windows, when I put to or get from queue a simple message from command line like: “amqsput” or “amqsget“, I would get some log files containing information like time, message data, queue name, etc.
That’s what I expect for my test program writen in Java, but when I used code below:
MQMessage msg = new MQMessage();
msg.writeUTF(“Hello, World!”);
MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.put(msg, pmo);
I got blank log file. Then I used code below:
MQMessage msg = new MQMessage();
msg.writeString(“Hello, World!”);
MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.put(msg, pmo);
Then I saw familar data in log file.
I opened MQ explorer, I saw two messages in “Message Browser”:
Hello, World!
%Hello, World!
I’m totally lost here, where is this “%” from? My api exit didn’t record the put action because of the encoding?
Any advices would be appreciated!
Thank you!
I’m pretty certain I remember reading somewhere that
writeUTF()outputs length information as well as the string.Ah, yes, here it is:
From IBM’s own doco on
WriteUTF():(my italics). As you’ve already discovered,
WriteString()is the way to do it without a length.