Reputation: 4490
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
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.
Upvotes: 0
Views: 2256
Reputation: 525
I have also encountered this problem, the documentation states that the default value of the parameter is none
, but in fact markerFile
is used. To resolve this, you must explicitly specify this parameter readLock=none
(camel-version 2.20.2)
Upvotes: 0
Reputation: 969
While this doesn't directly answer your question, I've used a trigger file (0 bytes) which the file watcher looks for. Your route would then work on the actual file to which the trigger is a companion. The trigger file is moved to a subdirectory /parent/.camel so it doesn't process again. Although we have noticed routes try to 'pick up' the actual file in a distributed environment where there is more than one server running the route.
Upvotes: 0
Reputation: 1537
The readLock-option only decides whether camel will try to acquire an exclusive read-lock on the file. There is another option called "readLockMarkerFile" which defaults to true, set that option to false and you should be fine.
<from uri="file:myDir?noop=true&filter=myFilter&scheduler=quartz2&scheduler.cron={{schedule}}&readLockMarkerFile=false/>
Upvotes: 2