message" /> Queues that contain messages of different lengths

 

Queues that contain messages of different lengths

Get a message with a buffer size of the expected message size. If you receive the return code indicating that the message is too long, get a bigger buffer. When the get fails in this way, the data length returned is the size of the unconverted message data. If you specify MQGMO_CONVERT on the MQGET call, and the data expands during conversion, it still might not fit in the buffer, in which case we need to further increase the size of the buffer.

If you issue the MQGET with a buffer length of zero, it returns the size of the message and the application can get a buffer of this size and reissue the get. If you have multiple applications processing the queue, another application might have already processed the message when the original application reissued the get. If you occasionally have very large messages, you might get a large buffer just for these messages, and release it after the message has been processed. This should help reduce virtual storage problems if all applications have very large buffers.

If your application cannot use messages of a fixed length, another solution to this problem is to use the MQINQ call to find the maximum size of messages that the queue can accept, then use this value in your MQGET call. The maximum size of messages for a queue is stored in the MaxMsgL attribute of the queue. This method could use large amounts of storage, however, because the value of this queue attribute could be as high as 100 MB, the maximum allowed by WebSphere MQ for z/OS.

Note:
We can lower the MaxMsgL parameter after large messages have been put to the queue. For example we can put a 100 MB message, then set MaxMsgL to 50 bytes. This means it is still possible to get bigger messages than the application expected.