1

First I had the following error: GenericFileOperationFailedException - Cannot change directory to: ..] I've fixed it by adding stepwise=false to the endpoint string:

sftp://sales.data.com:22/data/100?fileName=20190410.dat.gz&password=xxxxxx&stepwise=false&username=UserName

After that it failed with the below Error and I could not find any relevant information about fixing this. What could cause the problem here?

org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file: data/100/20190410.dat.gz
    at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:692)
    at org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:638)
    at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:411)
    at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:137)
    at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:226)
    at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:190)
    at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175)
    at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.InterruptedIOException
    at java.io.PipedInputStream.read(PipedInputStream.java:328)
    at java.io.PipedInputStream.read(PipedInputStream.java:377)
    at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2325)
    at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2351)
    at com.jcraft.jsch.ChannelSftp.access$800(ChannelSftp.java:36)
    at com.jcraft.jsch.ChannelSftp$2.read(ChannelSftp.java:1093)
    at com.jcraft.jsch.ChannelSftp$2.read(ChannelSftp.java:1053)
    at org.apache.camel.util.IOHelper.copy(IOHelper.java:204)
    at org.apache.camel.util.IOHelper.copy(IOHelper.java:169)
    at org.apache.camel.util.IOHelper.copyAndCloseInput(IOHelper.java:218)
    at org.apache.camel.util.IOHelper.copyAndCloseInput(IOHelper.java:214)
    at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:687)
samba
  • 2,821
  • 6
  • 30
  • 85
  • 1
    From SFTP are you trying to fetch single file named '20190410.dat.gz'. Check whether path you mentioned for file is correct or not, because message is showing as 'Cannot retrieve file' – Lucifer Apr 25 '19 at 06:10
  • @Lucifer yes, the path is correct, I've checked this – samba Apr 25 '19 at 09:54
  • Instead of trying with filename, try using ant include once. It may work. – Lucifer Apr 25 '19 at 11:03
  • @Lucifer what is include once? Can I pass it as a parameter to the endpoint string? I'm not configuring it from Java code or anything like that – samba Apr 25 '19 at 13:20
  • Are you using spring dsl or java dsl for coding. I mean her is antInclude which is one function we can used to pick file.Refer this 'https://camel.apache.org/file2.html' – Lucifer Apr 26 '19 at 10:37

1 Answers1

1

Use a readLock on your consumer, making it wait until the file has been fully FTP-ed. In the Camel documentation for ftp, look for this option:

  • readLock-changed

The idea is: tell Camel not to read the file when it sees it, but to keep checking to see if it is growing in size. As long as it keeps growing, Camel will wait. You can change related options to determine how long to wait, etc. Search through that page for all mentions of "readLock" to find more.

Darius X.
  • 2,886
  • 4
  • 24
  • 51