ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Segmentation problem: message too large

Post new topic  Reply to topic Goto page Previous  1, 2
 Segmentation problem: message too large « View previous topic :: View next topic » 
Author Message
Biju
PostPosted: Tue Nov 22, 2005 3:09 am    Post subject: Reply with quote

Acolyte

Joined: 03 Oct 2005
Posts: 71

Hi Guys,
Sorry to post in a dead thred. But I would like to know why is and integer used in the folowing code

Quote:
int i = 0;

while ((i = fileInput.read()) != -1) {
m.write(i);


Is there any specific reason for it. Can't we use a bye[] and read the whole file at once which will improve perfomance. Just a thought...if any one interested please explain or correct me.
Regards,
Bijish
Back to top
View user's profile Send private message Yahoo Messenger
Tibor
PostPosted: Tue Nov 22, 2005 5:47 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

Biju,

There would be some contact admin side-effect when you read the full file content without knowing its real length

Tibor
Back to top
View user's profile Send private message
Biju
PostPosted: Tue Nov 22, 2005 9:02 pm    Post subject: Reply with quote

Acolyte

Joined: 03 Oct 2005
Posts: 71

Hello Tibor,
Thank you for your reply...but how about this code segment.....
Quote:
FileInputStream inputFile = new FileInputStream(file);
int filesize = inputFile.available();
byte[] b = new byte[filesize];
int i = 0;

while ((i = inputFile.read(b)) != -1)
{
msg.write(b);
}

queue.put(msg, putMsgOption);
qMgr.commit();

Here we will get the length and hence I guess it should work fine. What do you think? In fact it makes the program atleast 100 times faster if the file size is in MBs....wouldnt it? Any corrections will be apreciated. Thank you again.
Regards,
Bijish
Back to top
View user's profile Send private message Yahoo Messenger
Tibor
PostPosted: Thu Nov 24, 2005 5:22 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

Code:
 byte[] b = new byte[filesize];

I find it very harmful, when a user starts your program with a huge file. This will cause a pretty memory allocation error I recommend you to consider the max message length (depend on queue and/or channel) and re-think this application.

HTH,
Tibor
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 25, 2005 5:46 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20763
Location: LI,NY

As well if you are worried about performance check java.nio.*. This is the fastest way to handle files (need java 1.4 or above).

Enjoy
Back to top
View user's profile Send private message Send e-mail
arfinn
PostPosted: Wed Apr 12, 2006 3:31 am    Post subject: Re: Segmentation problem: message too large Reply with quote

Newbie

Joined: 12 Apr 2006
Posts: 1

hopsala wrote:
pawanwatt_008 wrote:
Just change the value (Increase to some upper limit) of MAXMSGL on Server connection channel. Then it works like a breeze.

?!

Dude/t, did you look at the date? This thread is dead and buried. Not only that, but your answer was off the mark - he specifically stated "since I'm attempting to do segmentation". Please don't post unnecessarily


Stupid as it sounds, this is the correct answer; I found this thread through a google search an it helped to fix my own program.

Note that only the channel to the server needs the MAXMSGL increased, neither the queuemanager nor the queue have to be touched.


sorry if this is answered else where....
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum Index » IBM MQ Java / JMS » Segmentation problem: message too large
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.