Troubleshooting
Problem
Your WebSphere MQ java client application read messages without error at WebSphere MQ v6, however, after upgrading to WebSphere MQ v7 you start seeing the error java.io.EOFException: MQJE086: End of file exception
Symptom
java.io.EOFException: MQJE086: End of file exception returned to the call message.readString()
Cause
The present application code would work only with the WMQ v6 client because in the message.readString() method of the WMQ v6 client, characters will be read until an End_Of_File is encountered in the message data. In the WMQ v7 client, the message.readString() method would attempt to read a number of characters equal to the 'length' passed to it as a parameter. If
this 'length' is more than the number of characters in the message data, then the EOF Exception is thrown.
Environment
WebSphere MQ version 7.0.1.n base java client application
Diagnosing The Problem
A stack trace would show EOFException is being thrown from the method readConvertedString():
java.io.EOFException: MQJE086: End of file exception
('MQMessag2.readConvertedString()').
at com.ibm.mq.MQMessage.readConvertedString(MQMessage.java:3190)
at com.ibm.mq.MQMessage.readStringOfCharLength(MQMessage.java:1253)
at com.ibm.mq.MQMessage.readString(MQMessage.java:1844)
Resolving The Problem
1. Use the method getMessageLength() rather than getTotalMessageLength(). The getMessageLength() method returns the number of bytes of message data in that particular message.
2. Since the method message.readString() is deprecated in version 7, the method readStringOfBytesLength() should be used instead.
Hence your code should be changed to look similar to the example below:
new StringBuffer(
message.readStringOfByteLength(message.getMessageLength()) ;
Using this method as in the example above will ensure that the parameter 'length' passed to the readStringOfByteLength() is never greater than the number of characters in the message data.
Historical Number
PMR 10947;L6Q;000
Product Synonym
IBMMQ WMQ MQ
Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21504021