[ 
https://issues.apache.org/activemq/browse/CAMEL-2776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59631#action_59631
 ] 

Claus Ibsen commented on CAMEL-2776:
------------------------------------

@Willem

Yeah that is right. I kinda thought of that too this morning.

So if the OnCompletion will _enrich_ the stream with a DeleteFileOnCloseStream 
then the Camel component can use the stream to send back the reply and when it 
closes it, the file will be deleted as well.

The only concern would be what if that stream is *not* closed or used after the 
on completion? Then the file is not deleted and kept on file system to take up 
space.



> Cached stream file deletion causing file not found errors
> ---------------------------------------------------------
>
>                 Key: CAMEL-2776
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2776
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.3.0
>            Reporter: Roland Knight
>             Fix For: 2.4.0, 2.5.0
>
>
> Cached streams larger than the threshold (64K by default) are almost 
> impossible to work with since when a cached stream is closed, the cached file 
> is deleted. This occurs as a side effect of converting the associated body to 
> string which can occur frequently if tracing is turned on. The net result is 
> file not found errors shown below. The only workaround is to increase the 
> threshold to a large value to keep the body in memory.
> It seems that if stream caching is to be useful, the cached files should be 
> kept in a map and cleaned up and the end of the route, rather than upon close.
> Work around (set threshold to 10M):
>     camelContext.getProperties().put(CachedOutputStream.THRESHOLD, 
> "10000000");
> Error without work around:
> 16:09:49.278 [main] ERROR o.a.c.c.t.TimerConsumer - Error processing 
> exchange. Exchange[Message: [Body is instance of java.io.InputStream]]. 
> Caused by: [org.apache.camel.RuntimeCamelException - 
> java.io.FileNotFoundException: 
> C:\Users\ROLAND~1\AppData\Local\Temp\camel-tmp-594543\cos3643004935230268170.tmp
>  (The system cannot find the file specified)]
> org.apache.camel.RuntimeCamelException: java.io.FileNotFoundException: 
> C:\Users\ROLAND~1\AppData\Local\Temp\camel-tmp-594543\cos3643004935230268170.tmp
>  (The system cannot find the file specified)
>       at 
> org.apache.camel.converter.stream.FileInputStreamCache.reset(FileInputStreamCache.java:65)
>       at 
> org.apache.camel.util.MessageHelper.resetStreamCache(MessageHelper.java:106)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.deliverToFailureProcessor(RedeliveryErrorHandler.java:344)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:111)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>       at 
> org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>       at 
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>       at org.apache.camel.processor.Pipeline.process(Pipeline.java:75)
>       at 
> org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:80)
>       at 
> org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>       at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>       at 
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:44)
>       at 
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:106)
>       at 
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:104)
>       at 
> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:189)
>       at 
> org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:103)
>       at 
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:87)
>       at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>       at 
> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>       at 
> org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>       at 
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:173)
>       at 
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
>       at 
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
>       at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>       at 
> org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>       at 
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>       at org.apache.camel.processor.Pipeline.process(Pipeline.java:75)
>       at 
> org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:70)
>       at 
> org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>       at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>       at 
> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:102)
>       at 
> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)
>       at java.util.TimerThread.mainLoop(Timer.java:512)
>       at java.util.TimerThread.run(Timer.java:462)
> Caused by: java.io.FileNotFoundException: 
> C:\Users\ROLAND~1\AppData\Local\Temp\camel-tmp-594543\cos3643004935230268170.tmp
>  (The system cannot find the file specified)
>       at java.io.FileInputStream.open(Native Method)
>       at java.io.FileInputStream.<init>(FileInputStream.java:106)
>       at 
> org.apache.camel.converter.stream.FileInputStreamCache.reset(FileInputStreamCache.java:63)
>       ... 36 common frames omitted

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to