You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Harini Vaidhyanathan (JIRA)" <ji...@apache.org> on 2016/04/05 22:42:25 UTC

[jira] [Created] (CAMEL-9820) SFTP readLock=changed does not work with readLockMinAge option

Harini Vaidhyanathan created CAMEL-9820:
-------------------------------------------

             Summary: SFTP readLock=changed does not work with readLockMinAge option
                 Key: CAMEL-9820
                 URL: https://issues.apache.org/jira/browse/CAMEL-9820
             Project: Camel
          Issue Type: Bug
    Affects Versions: 2.16.1
            Reporter: Harini Vaidhyanathan


For the feature I am building, I need to use SFTP to fetch files to process. When it comes to large files, I want to be able to pick up a file for processing only when its been completely written. In order to achieve this, I tried the following combination suggesting the file age should be 10 minutes or more.

readLock=changed
readLockMinAge=10m 

This did not work as expected and kept picking up the files in the next poll as soon as the write has started. I found the following while debugging.

In class SftpChangedExclusiveReadLockStrategy,  

long startTime = (new Date()).getTime();  ==> returns time in milliseconds as long
newLastModified = f.getAttrs().getMTime();  ==> returns time in seconds as int casted to long.

Hence when the following check is made, the comparison becomes to be between newLastModified which is in seconds and newOlderThan in milliseconds hence never quite honoring the readLockMinAge specified.

(minAge != 0 && newLastModified < newOlderThan)

It looks like there should be 
newLastModified = f.getAttrs().getMTime() * 1000; 
to convert this to milliseconds.




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)