Hi

The changed read-lock is not for competing consumers. But its for "the
file is currently being written and is not ready for any consumer to
download the file .. problem".

For competing consumers across nodes you need a read lock and
idempotent repository that works for these uses cases. If you have a
copy of the CiA2 book then this is covered in the clustering chapter.

On Fri, Jan 10, 2020 at 2:23 AM Mark Harris
<mark.har...@intellihub.co.nz> wrote:
>
> Hello,
>
> I'm using Apache Camel version 2.24.2.
>
> I a Camel route that is processing files located an sFTP server. There are 
> multiple nodes running the application where the route is located, so I have 
> added file locking in an attempt to ensure only a single node process each 
> file.
>
> The route URI looks like this:
> sftp://<user>@<server>:<port>/<folder>?password=<password>&readLock=changed&readLockMinAge=10s&delete=true&delay=60s&include=<file
>  mask>
>
> The route looks like this:
> from(inUri).id("myId")
>   .idempotentConsumer(header(Exchange.FILE_NAME), 
> messageIdRepository).eager(true).skipDuplicate(true)
>   .log(LoggingLevel.INFO, "Processing file:  ${file:name}")
>   // Save original file in archive directory.
>   .to(archiveUri)
>   ... do other stuff...
>
> Every now and then, I'm getting what looks like file contention warning 
> messages:
>
> Error processing file RemoteFile[<file>] due to
>   Cannot retrieve file: <file>. Caused by: 
> [org.apache.camel.component.file.GenericFileOperationFailedException - Cannot 
> retrieve file: <file>]
>   org.apache.camel.component.file.GenericFileOperationFailedException: Cannot 
> retrieve file: <file>
>     Caused by: com.jcraft.jsch.SftpException: No such file
>
> ... and also these:
>
> Error during commit. Caused by: 
> [org.apache.camel.component.file.GenericFileOperationFailedException - Cannot 
> delete file: <file>]
>   org.apache.camel.component.file.GenericFileOperationFailedException: Cannot 
> delete file: <file>
>     Caused by: com.jcraft.jsch.SftpException: No such file
>
> Have I missed anything in my setup?
>
> I've also tried adding the idempotent repository to the input URI, like this:
> sftp://<user>@<server>:<port>/<folder>?password=<password>&readLock=changed&readLockMinAge=<minAge>&delete=true&delay=<delay>&include=<file
>  
> mask>&idempotent=true&idempotentKey=$simple{file:name}&idempotentRepository=#messageIdRepository
>
> ... but am getting the same kind of errors.
>
> Thanks for any assistance,
>
> Mark



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to