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

Willem Jiang commented on CAMEL-2776:
-------------------------------------

We can't just delete the cached file on Exchange OnCompletion, as we may still 
need to access the CachedInputStream after that. 
You can see it from https://issues.apache.org/activemq/browse/CAMEL-2636.
I think we can mark the CachedInputStream can delete the file when the exchange 
onCompletion is called, and then the CachedInputStream is closed we can delete 
the file.
We don't delete the file before the onCompletion even the CachedInputStream is 
closed.

When we change to using HawtDB, we can do the same thing.

> 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