Handling messages greater than 4 MB long
Messages can be too large for the application, queue, or queue manager. Depending on the environment, IBM MQ provides a number of ways of dealing with messages that are longer than 4 MB.
We can increase the MaxMsgLength attribute up to 100 MB on all IBM MQ systems at V6 or later. Set this value to reflect the size of the messages using the queue. On IBM MQ systems other than IBM MQ for z/OS, we can also:
- Use segmented messages. (Messages can be segmented by either the application or the queue manager.)
- Use reference messages.
Each of these approaches is described in the remainder of this section.
Increasing the maximum message length
The MaxMsgLength queue manager attribute defines the maximum length of a message that can be handled by a queue manager. Similarly, the MaxMsgLength queue attribute is the maximum length of a message that can be handled by a queue. The default maximum message length supported depends on the environment in which we are working.
If we are handling large messages, we can alter these attributes independently on platforms other than z/OS. We can set the queue manager attribute value in the range 32768 bytes through 100 MB. Attention: On IBM MQ for z/OS the MaxMsgLength attribute of the queue manager is hard coded at 100 MB.On all platforms, we can set the queue attribute value in the range 0 through 100 MB.
After changing one or both of the MaxMsgLength attributes, restart the applications and channels to ensure that the changes take effect.
When these changes are made, the message length must be less than or equal to both the queue and the queue manager MaxMsgLength attributes. However, existing messages might be longer than either attribute.
If the message is too big for the queue, MQRC_MSG_TOO_BIG_FOR_Q is returned. Similarly, if the message is too big for the queue manager, MQRC_MSG_TOO_BIG_FOR_Q_MGR is returned.
This method of handling large messages is easy and convenient. However, consider the following factors before using it:
- Uniformity among queue managers is reduced. The maximum size of message data is determined by the MaxMsgLength for each queue (including transmission queues) on which the message will be put. This value is often defaulted to the queue manager's MaxMsgLength, especially for transmission queues. This makes it difficult to predict whether a message is too large when it is to travel to a remote queue manager.
- Usage of system resources is increased. For example, applications need larger buffers, and on some platforms, there might be increased usage of shared storage. Queue storage should be affected only if actually required for larger messages.
- Channel batching is affected. A large message still counts as just one message towards the batch count but needs longer to transmit, thereby increasing response times for other messages.
- Message segmentation
Use this information to learn about segmenting messages. This feature is not supported on IBM MQ for z/OS or by applications using IBM MQ classes for JMS.- Reference messages
Use this information to learn more about reference messages.Parent topic: Getting messages from a queue