WebSphere MQ JMS client: MQRC_TRUNCATED_MSG_FAILED may occur when MaxMsgLen is less than RequiredSize
In the WebSphere MQ queue manager trace, as a result of an MQ JMS call to get a message, the reason code MQRC_TRUNCATED_MSG_FAILED may occur when the value of MaxMsgLen size is less than the actual size of message. This is working as designed and not really an error.
When you enable the trace for the MQ queue manager that is interacting with an application that uses MQ JMS calls, you may find the information below in one of the trace logs:
07:26:39.529759 12320946.2912: RequiredSize: 4533, MaxMsgLen: 4096, CurBufLen: 12288, MinRead: 0, StrippedLen: 0
You see the reason code:
2080 MQRC_TRUNCATED_MSG_FAILED (Truncated message failed.)
In the above example, the MQ client's actual message size (RequiredSize) is set to 4533 bytes, while the MQ server set the maximum message length (MaxMsgLen) as 4096 bytes (4KB). The RequiredSize is larger than MaxMsgLen, generating the reason code 2080 MQRC_TRUNCATED_MSG_FAILED
Resolving the problem
The MQRC_TRUNCATED_MSG_FAILED is expected in this scenario.
The default buffer size for the message that the WebSphere MQ JMS client uses is 4KB (4096 bytes). So if the message is larger than this value, then the WMQ JMS client receives the reason code: MQRC_TRUNCATED_MSG_FAILED
It also receives the actual data length of the message. The JMS client then uses the actual data length to resize the data buffer and to resend the MQGET request. This processing should be transparent to the JMS application. So the JMS client had to issue two MQGETs in order to resize the buffer and then receive the message.
It is worth noting that when the byte buffer has been resized then any other MQGET requests (JMS receive calls) made using the same instance of the JMS MessageConsumer will result in that same resized byte buffer being used. This means that if the message size for the next messages are equal or less than the previous byte buffer then there is no need for 2 MQGET requests to be made.
If you wish to change the default size of the buffer, then this can be done by setting the following JVM property, where size_in_bytes is how large you want the default to be:
WebSphere MQ WMQ
More support for:
Software version: 7.0, 7.0.1, 7.1, 7.5
Operating system(s): AIX, HP-UX, Linux, Platform Independent, Solaris, Windows
Software edition: All Editions
Reference #: 1643828
Modified date: 17 July 2013