What is Apache Camel's File "camelLock"?
Asked Answered
E

1

8

Whenever I start a Camel route from a file URI, I see that Camel obtains a "lock" on the file. For instance, if the file is named myinput.xml, then Camel creates a "lock file" on it, in the same directory, called myinput.xml.camelLock.

  1. What is this and why does Camel use it?
  2. When does Camel "release" the lock file (delete it)?
  3. Most importantly, is there a way to configure the file URI to not lock at all (and if so, how)?
Engvall answered 31/1, 2014 at 17:34 Comment(2)
To anyone who wants to downvote this for lack of research, please give File2 a solid read. You'll see some documentation surrounding the notion of a readLock, but nowhere does it actually answer my questions!!!Engvall
readLock=markerFile is the default which uses marker files, eg .camelLock.Hematuria
B
8

Hope this helps you my friend

readLocks is used by consumers, to only poll the files if it has exclusive read-lock on the file (i.e. the file is not in-progress or being written). Camel will wait until the file lock is granted after that Camel creates a marker file and then holds a lock on it camel maintain that lock as JDK IO API cannot always determine whether a file is currently being used by another process. The option readLockCheckInterval can be used to set the check frequency. This option is only avail for the FTP component from Camel 2.8 onwards. Notice that from Camel 2.10.1 onwards the FTP option fastExistsCheck can be enabled to speedup this readLock strategy.

Notice from Camel 2.10 onwards the read locks changed, fileLock and rename will also use a markerFile as well, to ensure not picking up files that may be in process by another Camel consumer running on another node (eg cluster). This is only supported by the file component (not the ftp component).

Baty answered 31/1, 2014 at 17:52 Comment(2)
Thanks @girishlalwani2010 (+1) - do you know if it's possible to either: (1) configure Camel not to lock at all, or (2) to force Camel to release the lock? Thanks again!Engvall
@TotesMcGotes try to configure token in the configuration of your apache camel readLock=noneBaty

© 2022 - 2024 — McMap. All rights reserved.