【问题标题】:How to fix the error: org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file?如何修复错误:org.apache.camel.component.file.GenericFileOperationFailedException:无法检索文件?
【发布时间】:2019-09-14 02:37:05
【问题描述】:

首先我遇到以下错误:GenericFileOperationFailedException - Cannot change directory to: ..] 我已通过将stepwise=false 添加到端点字符串来修复它:

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

之后它因以下错误而失败,我找不到任何有关解决此问题的相关信息。什么可能导致这里的问题?

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)

【问题讨论】:

  • 您是否尝试从 SFTP 获取名为“20190410.dat.gz”的单个文件。检查您提到的文件路径是否正确,因为消息显示为“无法检索文件”
  • @Lucifer 是的,路径是正确的,我已经检查过了
  • 不要尝试使用文件名,而是尝试使用一次 ant include。它可能会起作用。
  • @Lucifer 包含一次是什么?我可以将它作为参数传递给端点字符串吗?我不是从 Java 代码或类似的东西配置它
  • 您是使用spring dsl还是java dsl进行编码。我的意思是她是 antInclude,这是我们可以用来选择文件的一个函数。参考这个'camel.apache.org/file2.html'

标签: io apache-camel sftp camel-ftp


【解决方案1】:

在您的消费者上使用 readLock,使其等到文件完全通过 FTP 编辑。 在Camel documentation for ftp 中,查找此选项:

  • readLock 已更改

这个想法是:告诉 Camel 在看到文件时不要读取文件,而是继续检查文件大小是否在增长。只要它继续增长,骆驼就会等待。您可以更改相关选项以确定等待多长时间等。在该页面中搜索所有提及“readLock”以查找更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-12
    • 1970-01-01
    • 2019-12-08
    • 1970-01-01
    相关资源
    最近更新 更多