I'm consuming a file using Camel File component as follows:
<from uri="file:myDir?noop=true&filter=myFilter&scheduler=quartz2&scheduler.cron={{schedule}}/>
The source location is read only. Camel File documentation says, it won't be using a read lock by default.
But, I'm getting a permission denied exception while running this code.
Endpoint[file://myFile?filter=myFilter&idempotent=true&noop=true&scheduler=quartz2&scheduler.cron={{mySchedule}} cannot begin processing file: GenericFile[myDir\myFile] due to: Access is denied. Caused by: [java.io.IOException - Access is denied]
Stack Trace java.io.IOException: Permission denied at java.io.UnixFileSystem.createFileExclusively(Native Method)[:1.8.0_66] at java.io.File.createNewFile(File.java:1012)[:1.8.0_66] at org.apache.camel.util.FileUtil.createNewFile(FileUtil.java:587)[org.apache.camel:camel-core:2.15.1.redhat-621090 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2] at org.apache.camel.component.file.strategy.MarkerFileExclusiveReadLockStrategy.acquireExclusiveReadLock(MarkerFileExclusiveReadLockStrategy.java:71)[org.apache.camel:camel-core:2.15.1.redhat-621090 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2] at org.apache.camel.component.file.strategy.GenericFileProcessStrategySupport.begin(GenericFileProcessStrategySupport.java:49)[org.apache.camel:camel-core:2.15.1.redhat-621090 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2] at org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.begin(GenericFileRenameProcessStrategy.java:35)[org.apache.camel:camel-core:2.15.1.redhat-621090 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2] at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:352)[org.apache.camel:camel-core:2.15.1.redhat-621090 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2] at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:211)[org.apache.camel:camel-core:2.15.1.redhat-621090 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2] at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:175)[org.apache.camel:camel-core:2.15.1.redhat-621090 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2] at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)[org.apache.camel:camel-core:2.15.1.redhat-621090 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2] at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)[org.apache.camel:camel-core:2.15.1.redhat-621090 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2] at org.apache.camel.pollconsumer.quartz2.QuartzScheduledPollConsumerJob.execute(QuartzScheduledPollConsumerJob.java:59)[org.apache.camel:camel-quartz2:2.15.1.redhat-621090] at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[org.quartz-scheduler:quartz:2.2.1] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[org.quartz-scheduler:quartz:2.2.1]
From the stack trace, it appears that, camel is trying to create a readLock and it is causing exception due to lack of of permission.
So, my questions are
- Why camel is using a lock, even if default value of read lock is none
- If this is expected behavior, how can I consume file from a read only location where I don't have write permission?
UPDATE
I tried setting readLockMarkingFile to false as suggested in one of the answer, but that did n't solve the problem. So, I explicitly set readLock to none. Now, it is working. Don't know, why readLock is not none by default as mentioned in documentation.