camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "willem.jiang" <willem.ji...@gmail.com>
Subject Re: StreamCaching in Camel 1.6
Date Tue, 03 Mar 2009 10:58:43 GMT

Hi 

Just as Gert said.
In CXF , we will cache the big message into the File instead of the memory.
I think we could do the same thing in Camel.
I just filled a JIRA[2] for it.

[1] http://www.nabble.com/Re%3A-StreamCaching-in-Camel-1.6-to22305858.html
[2] https://issues.apache.org/activemq/browse/CAMEL-1413

Willem


_Jens wrote:
> 
> 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-tp22305654p22306407.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Mime
View raw message