Hi,

I have run into a problem with stream caching in Camel 1.6. I have a route
that reads data via streaming from an Http request. In some cases this can
be a large amount of data, so I cannot stream the data completely into
memory. I wrote this little test to demonstrate my problem:

    @Test
    public void testUploadFailsForHugeFile() throws Exception {        
        CamelContext context = new DefaultCamelContext();
        
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                noStreamCaching();
                from("jetty:http://localhost:8989/bigfile";)
                    .noStreamCaching()
                    .process(new Processor() {
                        public void process(Exchange exchange) throws
Exception {
                            InputStream inputStream =
exchange.getIn().getBody(InputStream.class);
                            while (inputStream.read() != -1) {}
                        }
                    });
            }            
        });
        
        context.start();
        
        HttpClient client = new HttpClient();
        PostMethod method = new PostMethod("http://localhost:8989/bigfile";);
        File file = new File("c:\\temp\\test.bin.ok2");
        method.setRequestEntity(new FileRequestEntity(file,
"unknown/unknown"));
        assertEquals(200, client.executeMethod(method));
    }    

This fails with an OutOfMemoryError if test.bin.ok2 is a larger file because
the StreamCachingInterceptor reads the input stream into memory. Now I
understand that stream caching is turned on by default in Camel 1.6.
However, as you can see I tried to disable it in the route builder. This
seems not to make any difference.

Now, my question is if there is some other way to disable stream caching or
if I'm doing something wrong here.

Thanks in advance
Jens
-- 
View this message in context: 
http://www.nabble.com/StreamCaching-in-Camel-1.6-tp22305654p22305654.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.

Reply via email to