I have been away from this project for quite some time but I vaguely remember something about the "storage" package.
I think ThresholdStorageProvider [1] should do what you want. Create your own StorageBodyFactory [2] and use it with DefaultMessageBuilderl#setBodyFactory [3]. Also have a look at the DOM samples under org.apache.james.mime4j.samples.dom. I am not very familiar with the current state of the API but I hope that helps. [1] https://james.apache.org/mime4j/apidocs/org/apache/james/mime4j/storage/ThresholdStorageProvider.html [2] https://james.apache.org/mime4j/apidocs/org/apache/james/mime4j/storage/StorageBodyFactory.html [3] https://james.apache.org/mime4j/apidocs/org/apache/james/mime4j/message/DefaultMessageBuilder.html#setBodyFactory%28org.apache.james.mime4j.message.BodyFactory%29 On Mon, Sep 21, 2015 at 6:30 PM, Andreas Joseph Krogh <[email protected]> wrote: > Hi all. > > We're using mime4j to read/parse messages and storing them in a database. > For large messages we get OutOfMemoryErrors because BasicBodyFactory and > BasicBinaryBody operate on byte[]. > > I see on this page: https://james.apache.org/mime4j/ > that the Message-class is referenced which according to the JavaDoc > operate on streams which looks like it would fit perfect for us. The > problem is that I cannot find this class anywhere. > > We're using the following code to parse an input-stream: > > > val messageBuilder = new DefaultMessageBuilder()val mimeConfig = new > MimeConfig() > mimeConfig.setMaxContentLen(-1) // disablemimeConfig.setMaxLineLen(-1) // > disablemimeConfig.setMaxHeaderCount(-1) // > disablemimeConfig.setMaxHeaderLen(-1) // disable > messageBuilder.setMimeEntityConfig(mimeConfig)val mimeMessage: Message = > messageBuilder.parseMessage(is) > > > > Can anyone please point me to the correct dependencies to be able to use > the Message-class instead, and hopefully some code-example of how to use it > to accomplish the same as the code above except with hopefully a lot less > memory-usage? > > Thanks. > > -- > *Andreas Joseph Krogh* > CTO / Partner - Visena AS > Mobile: +47 909 56 963 > [email protected] > www.visena.com > <https://www.visena.com> >
