How to configure the JavaMail fetchsize to be larger than the 16KB default

Solution Unverified - Updated -

Issue

We use JavaMail to poll an email inbox and pull information into our application. When we encounter an e-mail with a large attachment, for example 7MB, it can take 1-2 hours to process the e-mail. Sometimes we may also get an error like this:

java.lang.ArrayIndexOutOfBoundsException: message number (39) out of bounds (38)
        at com.sun.mail.imap.MessageCache.getMessage(MessageCache.java:132) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
        at com.sun.mail.imap.MessageCache.getMessageBySeqnum(MessageCache.java:162) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
        at com.sun.mail.imap.IMAPFolder.getMessageBySeqNumber(IMAPFolder.java:2809) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
        at com.sun.mail.imap.IMAPFolder.handleResponse(IMAPFolder.java:2486) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
        at com.sun.mail.iap.Protocol.notifyResponseHandlers(Protocol.java:216) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
        at com.sun.mail.imap.protocol.IMAPProtocol.fetchBody(IMAPProtocol.java:1319) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
        at com.sun.mail.imap.protocol.IMAPProtocol.fetchBody(IMAPProtocol.java:1306) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
        ...

We think it has to do with the default fetchsize setting and we are not sure how to update the setting.

  • Can you help us configure the fetchsize to be larger than the 16KB default?
  • Do you have a recommendation for an optimal setting or how to determine an optimal setting?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 5.x
    • 6.x
  • JavaMail

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.