Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9820

SFTP readLock=changed does not work with readLockMinAge option

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.16.1
    • 2.16.4, 2.17.1, 2.18.0
    • None
    • None
    • Novice

    Description

      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.

      Attachments

        Activity

          People

            acosentino Andrea Cosentino
            _harini_ Harini Vaidhyanathan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: