Ways to handle large messages in WebSphere MQ
As readers who have used WebSphere MQ know, WebSphere MQ is limited in size to the single message being processed, the maximum message currently supported is 100M, and the performance of WebSphere MQ processing decreases as the message size increases. From best practices, the message of WebSphere MQ transmission size of k is the most efficient. So how can WebSphere MQ efficiently handle big messages?
WebSphere MQ provides two ways to handle large messages: message fragmentation and message grouping. Let's look at how to implement message fragmentation and grouping when writing WebSphere MQ programs using the Java API.
Message fragmentation
Message fragmentation is the practice of dividing the application of a large logical message into a small fragment, each of which is transmitted independently as a WebSphere MQ message, identified by the GroupId, Msgseqnumber, and Offset 3 attributes in MQMD, and the starting message's Offs The ET value is 0, and the last message is identified with the following tag this is the last fragment: Mqmf_last_segment.
Specifically, message fragmentation can be divided into two modes: one is to implement the message fragmentation and assembly automatically by the queue manager, and the other is to implement the fragmentation and assembly of messages by the application. We'll give you a detailed description of both implementations below.
Message fragmentation automatically implemented by Queue Manager
As the name implies, the Queue Manager automatically implemented message fragmentation is the Queue manager to complete the message fragmentation and assembly. For an application, whether it is a sender or a receiver, it handles a full, large message, except that the queue Manager splits the message and transmits it in the program by setting some identities. Therefore, this approach applies where WebSphere MQ is not suitable for transmitting large messages for transmission efficiency reasons, and applications can handle large messages, allowing for a chunk of memory to be consumed. Also, this approach is simpler for writing applications.
When you are actually programming with the Java API, for the sender, you need to set the message when sending the message messageflags as follows:
Msg.messageflags = MQC. mqmf_segmentation_allowed;
For receivers, you need to set mqgetmessageoptions when receiving messages:
MQGetMessageOptions gmo = new MQGetMessageOptions ();
gmo.options = MQC.MQGMO_COMPLETE_MSG;