我正在尝试使用 Camel FTP 组件(Camel 2.19.0)检索文件:
from("ftp://my.host.com:21/my/relative/directory?download=true&stepwise=false&delete=false")
Camel 正在正确连接并列出目录中的文件,但是当它去处理它们时,它会为每个文件抛出以下异常:
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file: RemoteFile[my/relative/directory/file1.txt] from: ftp://my.host.com:21/my/relative/directory?delete=false&download=true&stepwise=false
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:427)
at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:137)
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:218)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:182)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
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:748)
从 TRACE 日志中,我可以看到 Camel 正确列出了目录中的文件:
[TRACE] 2017-09-05 11:40:49,438 org.apache.camel.component.file.remote.FtpConsumer - Polling directory: my/relative/directory
[TRACE] 2017-09-05 11:40:51,748 org.apache.camel.component.file.remote.FtpOperations - listFiles(my/relative/directory)
[TRACE] 2017-09-05 11:40:58,657 org.apache.camel.component.file.remote.FtpConsumer - Found 3 in directory: my/relative/directory
[TRACE] 2017-09-05 11:40:58,657 org.apache.camel.component.file.remote.FtpConsumer - FtpFile[name=/absolute/path/to/directory/file1.txt, dir=false, file=true]
[TRACE] 2017-09-05 11:40:58,657 org.apache.camel.component.file.remote.FtpConsumer - FtpFile[name=/absolute/path/to/directory/file2.txt, dir=false, file=true]
[TRACE] 2017-09-05 11:40:58,657 org.apache.camel.component.file.remote.FtpConsumer - FtpFile[name=/absolute/path/to/directory/file3.txt, dir=false, file=true]
但是,当 Camel 尝试处理每个文件时,它似乎将相对目录添加到绝对目录之前,并且无法找到生成的乱码路径:
[TRACE] 2017-09-05 11:40:59,417 org.apache.camel.component.file.remote.FtpConsumer - Processing file: RemoteFile[absolute/path/to/directory/file1.txt]
[TRACE] 2017-09-05 11:40:59,418 org.apache.camel.component.file.remote.FtpConsumer - Retrieving file: my/relative/directory//absolute/path/to/directory/file1.txt from: ftp://my.host.com:21/my/relative/directory?delete=false&download=true&stepwise=false
[TRACE] 2017-09-05 11:40:59,418 org.apache.camel.component.file.remote.FtpOperations - retrieveFile(my/relative/directory//absolute/path/to/directory/file1.txt)
[TRACE] 2017-09-05 11:40:59,418 org.apache.camel.component.file.remote.FtpOperations - Client retrieveFile: my/relative/directory//absolute/path/to/directory/file1.txt
[WARN ] 2017-09-05 11:40:59,518 org.apache.camel.component.file.remote.FtpConsumer - Error processing file RemoteFile[absolute/path/to/directory/file1.txt] due to Cannot retrieve file: RemoteFile[absolute/path/to/directory/file1.txt] from: ftp://my.host.com:21/my/relative/directory?delete=false&download=true&stepwise=false
FTPComponent构建的日志中的这条路径不正确:
检索文件:my/relative/directory//absolute/path/to/directory/file1.txt
我调试了 Camel FTP 消费者,看起来第 238 行是相对路径被添加到绝对路径的位置
有趣的是,SFTP 组件正在做同样的事情,但它正在工作,因为RemoteFileOperations<ChannelSftp.LsEntry>
它没有将文件名设置为绝对路径,但RemoteFileOperations<FTPFile>
确实如此。
有没有人有任何建议来解决这个问题以让 FTP 组件使用文件?还是我做错了什么?
我正在使用骆驼 2.19.0