Author |
Message
|
vivekj |
Posted: Mon Apr 23, 2007 9:13 pm Post subject: Segmentation of Messages |
|
|
Newbie
Joined: 23 Apr 2007 Posts: 5
|
Hi,
I have a requirement of Partitioning a Single MQ Message while receiving.
The Message is about 4 MB in size, and i have to GET the message in CHUNKS of a specified size say 1024 bytes. But when i issue a Receive method call (am implementing a JMS Client for MQ) on my QueueReceiver, it returns me the whole message.
Any ideas how to solve my requirement problems.
Will be really grateful to all of you.
Regards,
Vivek |
|
Back to top |
|
 |
vivekj |
Posted: Mon Apr 23, 2007 10:05 pm Post subject: java.lang.OutOfMemoryError |
|
|
Newbie
Joined: 23 Apr 2007 Posts: 5
|
Hi,
Continuing on the same question, i got java.lang.OutOfMemoryError when i try receiving Large Data > 15 - 20 Mb as a Single Message from MQ using my JMS Client. Any ideas how to resolve this WITHOUT Increasing Java Heap Size. ??
Regards, |
|
Back to top |
|
 |
jsware |
Posted: Mon Apr 23, 2007 11:19 pm Post subject: |
|
|
 Chevalier
Joined: 17 May 2001 Posts: 455
|
You cannot receive a "chunk" of your message unless the message is physically segmented on the queue. MQ requires that you get (at least) one physical message per MQGET call. You cannot get part of a message and then the next part unless your logical message is physically segmented into multiple messages on the queue.
The allow truncated message will not help, unless you are not interested in the rest of your message. While it may seem to allow you to get part of a message because only the first n bytes will be returned, the whole message is removed from the queue and bytes n+1 onwards are lost.
If you have control over the sending app, you need to change it there to either set the allow segmentation flag or manually segment messages. _________________ Regards
John
The pain of low quaility far outlasts the joy of low price. |
|
Back to top |
|
 |
vivekj |
Posted: Tue Apr 24, 2007 12:14 am Post subject: |
|
|
Newbie
Joined: 23 Apr 2007 Posts: 5
|
Thanks for replying.
So how to avoid the error of Out of Memory of Java Heap without Increasing the Heap size. Any alternatives ?
Regards,
Vivek |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Apr 24, 2007 5:10 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I seem to remember someone much smarter than me posting something about using segmentation only on the receiving end...
But that would have been several months ago. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
tleichen |
Posted: Tue Apr 24, 2007 5:51 am Post subject: |
|
|
Yatiri
Joined: 11 Apr 2005 Posts: 663 Location: Center of the USA
|
vivekj wrote: |
Thanks for replying.
So how to avoid the error of Out of Memory of Java Heap without Increasing the Heap size. Any alternatives ?
Regards,
Vivek |
You really have two choices:
Either break up the message into multiple messages (which will require some way of handling them at the receiving end), as Scott said.
or Increase the heap size. That isn't really that hard to do.  _________________ IBM Certified MQSeries Specialist
IBM Certified MQSeries Developer |
|
Back to top |
|
 |
jsware |
Posted: Wed Apr 25, 2007 3:56 am Post subject: |
|
|
 Chevalier
Joined: 17 May 2001 Posts: 455
|
vivekj wrote: |
So how to avoid the error of Out of Memory of Java Heap without Increasing the Heap size. Any alternatives ? |
Refactor your code to use less memory, making more available for your message handling classes  _________________ Regards
John
The pain of low quaility far outlasts the joy of low price. |
|
Back to top |
|
 |
vivekj |
Posted: Wed Apr 25, 2007 8:19 pm Post subject: |
|
|
Newbie
Joined: 23 Apr 2007 Posts: 5
|
Hi,
Increasing the Java Heap is the most obvious solution to this problem. But we Cannot dynamically increase the Heap size, as i am expecting a very variable flow of data starting from 4 MB. To set up an upper limit on the heap size would constraint my application, in case there is an incoming of message size more than Heap size.
Also, the cost of receiving the Message Once again in the event of Failure can be a Disadvantage to the Receiver Application.
Regards,
Vivek |
|
Back to top |
|
 |
kevinf2349 |
Posted: Thu Apr 26, 2007 7:06 am Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
Just make your application handle the largest possible MQ message size, if you really don't know the maximum size is going to be on the incoming message then I don't see what your other options are....assuming segmentation doesn't meet your needs. |
|
Back to top |
|
 |
vivekj |
Posted: Thu Apr 26, 2007 9:47 pm Post subject: |
|
|
Newbie
Joined: 23 Apr 2007 Posts: 5
|
Is there any configuration that i can do ONLY at the Server to SEGMENT any message that comes in. Thereby i can avoid controlling the Sender Application from Manual segmentation.
I mean a setting like AUTOMATIC SEGMENTATION or something explicitly segmenting ALL messages.
If there is any setting like this, then i can Direct my RECEIVER Application to Receive them in Chunks.
Regards,
Vivek |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Thu Apr 26, 2007 10:29 pm Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
You can use segmentation by QMGR but still your application has to be prepared for this by adding additionat options, MQC.MQGMO_COMPLETE_MSG for reading and MQC.MQMF_SEGMENTATION_ALLOWED for putting.
This option tells QMGR to use segmentation on fly.
Reading
Code: |
...
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_FAIL_IF_QUIESCING|MQC.MQGMO_COMPLETE_MSG;
queueIN.get(retrievemqmessage, gmo);
... |
Putting
Code: |
...
message.messageFlags=MQC.MQMF_SEGMENTATION_ALLOWED;
queue.put(message,pmo);
... |
_________________ Marcin |
|
Back to top |
|
 |
|