I'm noticed an intermittent exception be thrown in my application. It usually
happens after uploading a large file. It seems to happen whenever the
fileConsumer is attempting to poll a file that is been written too. 
I expected the fileConsumer only to poll the file when it has an
exclusiveReadLock on the file.

I can replicate the problem by dropping a file into the server and quickly
opening the file with excel. ( This will hold a lock on the file) after 30
secs or so the exception is thrown.

<code>
java.io.FileNotFoundException:
c:\temp\File_20081120_17-Dec-2008_14-15-59.txt (The
process cannot access the file because it is being used by another process)
        at java.io.RandomAccessFile.open(Native Method)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
        at
org.apache.camel.component.file.FileConsumer.acquireExclusiveReadLock(FileConsumer.java:2
04)
        at
org.apache.camel.component.file.FileConsumer.pollFile(FileConsumer.java:143)
        at
org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:89)
        at
org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:99)
        at
org.apache.camel.component.file.FileConsumer.poll(FileConsumer.java:65)
        at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Scheduled
ThreadPoolExecutor.java:98)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Schedule
dThreadPoolExecutor.java:181)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadP
oolExecutor.java:205)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
</code>

I had hope that after releasing the lock on the file (closing excel) the
fileConsumer would retry the poll.
However the file remains on the c:\\temp directory. Should the file
component not retry up to 6 times from my setup below.


errorHandler(deadLetterChannel("activemq:queue:errors").maximumRedeliveries(6).initialRedeliveryDelay(5000));
 

from("file://c://temp?delete=true&consumer.delay=30000&consumer.alwaysConsume=true&consumer.exclusiveReadLock=true").to("ftp://usern...@localhost?password=pass;binary=true)

Camel 1.5.0

Many Thanks
-- 
View this message in context: 
http://www.nabble.com/FileComponent-FileNotFoundException-tp21054406s22882p21054406.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to