Instead of using .unmarshall().gzip() I passed the message to a beanRef that
decompresses the payload to a temp file using a buffer.  Then created
another route to read from the temp file.  This gave much better memory
usage and I was able to handle 300mb -> 4mb compressed files without OOM
exceptions.

Is there an option to buffer/stream automatically when it comes to
unmarshalling?

@Handler
public void processMessage(Exchange message) throws Exception
{
                        
        //Decompress the file to a temp folder
        File file = new File(message.getIn().getHeader("CamelFilePath",
String.class));
                
        GZIPInputStream in = null;
        OutputStream out = null;
        File target = null;
        try 
        {
                //Open the compressed file
                in = new GZIPInputStream(new FileInputStream(file));

                //Open the output file
                target = new File("C:\\A2CMessaging\\Temp",file.getName());
                target.createNewFile();
                out = new FileOutputStream(target);

                //Transfer bytes from the compressed file to the output file
                //Buffer of 1 mb.
                byte[] buf = new byte[1048576];
                int len;
                while ((len = in.read(buf)) > 0) 
                {
                        out.write(buf, 0, len);
                }

                in.close();
                out.close();
        } 
        ....... try/catch/finally etc
                
}





--
View this message in context: 
http://camel.465427.n5.nabble.com/unmarshal-gzip-question-tp5727782p5727804.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to