Using the Java API to process WebSphere MQ large messages

Source: Internet
Author: User

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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.