Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Javamail IMAP Large Attachments Issue

843830Mar 16 2006 — edited Aug 25 2006
Hi,
I'm using the Javamail API for processing messages from a Microsoft Exchange server (5.5). Everything is functioning great, except when the attachments on the emails greater than a few megs.

If I attach multiple attachments that equal ~6megs everything runs very quickly, but if I place a 3meg attachment into an email and try to process it pulling the attachment takes significantly longer
(20 seconds to pull the 6 megs of attachments under 2megs vs. 6 minutes to pull the 6 meg attachment).

Below is the code I am currently using (content is the BodyPart for the attachment, this.content is an instance byte[]):
		try {
			int buffer_size = 51200;
			
			InputStream in=content.getInputStream();
			ByteArrayOutputStream bos=new ByteArrayOutputStream();
			byte[] buffer = new byte[buffer_size];
			while(true) {
				int n = in.read(buffer, 0, buffer_size);
				if(n == -1) break;
				bos.write(buffer, 0, n);
			}
			this.content = bos.toByteArray();
			bos = null;			
		} catch (Exception e) {
			e.printStackTrace();
		}
I have played with the buffer sizes to no-avail. I have also set the partial fetch and fetchsize properties for the IMAP connection to on/off to no avail. I have also tried setting the heap size to 512megs.

Personally I think this is either a bug with the JavaMail IMAP implementation or maybe an issue with Exchange's IMAP Server (Thunderbird functions pretty quickly with it however).

Help would be greatly appreciated,

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 22 2006
Added on Mar 16 2006
12 comments
1,972 views