camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gert Vanthienen <gert.vanthie...@gmail.com>
Subject Re: StreamCaching in Camel 1.6
Date Tue, 03 Mar 2009 10:13:39 GMT
Jens,

Stream caching is turned on automatically when you use a
DeadLetterChannel as the error handler.  Because the Exchange might be
redelivered or sent to the DLQ destination, we have to cache it before
we send it into the DLC.  Adding an errorHandler(noErrorHandler()); to
the configure() method should fix that for you.

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/3/3 _Jens <jens.riemschneider@icw.de>:
>
> 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.
>
>

Mime
View raw message