apache-camelcamel-ftp

Apache Camel SFTP Consumer not deleting file after reading


I see a weird behavior with Apache Camel SFTP. Even after setting the delete=true attribute, it doesn't delete the file after receiving. I am using 3.0.0-M3 version of camel-ftp

Following is my SFTP configuration,

sftp://<<HOST_NAME>>:<<PORT>>/<<PATH>>?username=<<USERNAME>>" +
                    "&password=<<PASSWORD>>" +
                    "&preferredAuthentications=password" +
                    "&readLock=changed" +
                    "&readLockMinAge=30000" +
                    "&delay=20000" +
                    "&delete=true";

Now Camel is able to read the file, but it doesn't delete the file after reading. While going through the docs, it says

delete (consumer) - If true, the file will be deleted after it is processed successfully.

After receiving the file all I am doing is pasing it to another route, like following,

from(endpointUri).to("direct:procesSftpFile");

Should I change it from direct to vm or seda?


Solution

  • Looks like nobody faced this issue and I somehow figured out the where this started happening.

    The issue was not because of Camel sftp component, but it was with the piece of code I was calling.

    Second part of my flow looks like this,

    from("direct:procesSftpFile")
    .log("...")
    // logging and other regular processing
    ....
    // sending to vm InOnly 
    .to("vm:queue1?exchangePattern=InOnly")
    .. some more processing..
    .to("vm:queue2?exchangePattern=InOnly")
    

    So the issue was with calling those queue1 and queue2 in above snipet.

    Commenting them, fixed it and sftp started deleting the files. For calling the VM, instead of to(), I used producerTemplate.asyncSend as workaround.

    One thing I am still confused about is, if we are using InOnly exchange pattern, then why it is affecting the sftp behavior ? Probably I should ask this in a separate question.