当前位置: 首页 > 知识库问答 >
问题:

Apache Camel不完全从SFTP下载某些文件

裴甫
2023-03-14

我一直在努力弄清楚为什么有些文件没有正确下载。似乎某些文件无法完全下载,即使在本地测试和重新启动我的应用程序时也是如此。使事情变得更加困难的是,它并不总是一致的。

    null

任何关于问题可能是什么的建议或如何排除故障的建议都将是非常棒的!

路由配置(有点人为创建,因为值来自spring-boot配置):

public class FileRouteBuilder extends RouteBuilder {
 // Cut

    @Override
    public void configure() throws Exception {

        errorHandler(deadLetterChannel("seda:"+ROUTE_ID_ERROR_EMAIL));      

        from("sftp://username@hostname/OUT?noop=true&streamDownload=true&password=password&include=Data_file.*csv&idempotentRepository=#keyRepo&greedy=true&delay=5m&maxMessagesPerPoll=10&readLock=changed")
        .id(routeConfig.getRouteId())
        .routeDescription(routeConfig.getRouteId())
        .setHeader(HEADER_FILE_SOURCE, constant(routeConfig.getRouteId()))
        .to("log:feeds." + routeConfig.getRouteId() + "?level=INFO&showAll=true")
        // Exclude all files oder than the specified number of hours
        .filter(new FileModifiedSincePredicate(24))
        .to(file:rootDir/DATA)
        .to("seda:" + ROUTE_ID_ACTIVITY_EMAIL_NOTIFICATION)
        .end();
       }
    }
}

更新1

添加binary=true后的观察。

前两个文件下载正确,但第三个也是服务器上的最后一个文件不正确。

193255587 Data_File_12.csv
191072548 Data_File_15.csv
139929360 Data_File_16.csv

teh data_file_16.csv文件的正确文件大小是192867682字节,它在camelfilelength标头中被正确捕获。

据我所知,日志没有显示任何可疑的东西,也没有提示_16文件没有被完全写入。

是否有人知道SFTP服务器上可能发生的任何事情值得向提供商检查?

o.a.c.c.file.remote.SftpConsumer         : Took 0.194 seconds to poll: OUT
o.a.c.c.file.remote.SftpConsumer         : Total 3 files to consume
o.a.c.c.file.remote.SftpConsumer         : About to process file: RemoteFile[Data_File_12.csv] using exchange: Exchange[]
o.apache.camel.processor.SendProcessor   : >>>> file://target/file-dest/MISA Exchange[ID-LON-2016-1516204084378-0-1]
o.a.camel.component.file.FileOperations  : Using InputStream to write file: target\file-dest\MISA\Data_File_12.csv
o.a.camel.converter.jaxp.XmlConverter    : Created TransformerFactory: com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl@d9dfe93
o.a.c.c.file.GenericFileProducer         : Wrote [target\file-dest\MISA\Data_File_12.csv] to [file://target/file-dest/MISA]
o.a.c.c.file.GenericFileOnCompletion     : Done processing file: RemoteFile[Data_File_12.csv] using exchange: Exchange[ID-LON-2016-1516204084378-0-1]
o.a.c.p.i.FileIdempotentRepository       : Appending Data_File_12.csv-193255587 to idempotent filestore: target\file-dest\.file-key-repo\repo
o.a.c.c.file.remote.SftpConsumer         : About to process file: RemoteFile[Data_File_15.csv] using exchange: Exchange[]
o.apache.camel.processor.SendProcessor   : >>>> file://target/file-dest/MISA Exchange[ID-LON-2016-1516204084378-0-2]
o.a.camel.component.file.FileOperations  : Using InputStream to write file: target\file-dest\MISA\Data_File_15.csv
o.a.c.c.file.GenericFileProducer         : Wrote [target\file-dest\MISA\Data_File_15.csv] to [file://target/file-dest/MISA]
o.a.c.c.file.GenericFileOnCompletion     : Done processing file: RemoteFile[Data_File_15.csv] using exchange: Exchange[ID-LON-2016-1516204084378-0-2]
o.a.c.p.i.FileIdempotentRepository       : Appending Data_File_15.csv-191072548 to idempotent filestore: target\file-dest\.file-key-repo\repo
o.a.c.c.file.remote.SftpConsumer         : About to process file: RemoteFile[Data_File_16.csv] using exchange: Exchange[]
o.apache.camel.processor.SendProcessor   : >>>> file://target/file-dest/MISA Exchange[ID-LON-2016-1516204084378-0-3]
o.a.camel.component.file.FileOperations  : Using InputStream to write file: target\file-dest\MISA\Data_File_16.csv
o.a.c.c.file.GenericFileProducer         : Wrote [target\file-dest\MISA\Data_File_16.csv] to [file://target/file-dest/MISA]
o.a.c.c.file.GenericFileOnCompletion     : Done processing file: RemoteFile[Data_File_16.csv] using exchange: Exchange[ID-LON-2016-1516204084378-0-3]
o.a.c.p.i.FileIdempotentRepository       : Appending Data_File_16.csv-192867682 to idempotent filestore: target\file-dest\.file-key-repo\repo

共有1个答案

陈茂
2023-03-14

啊,您在下载消息后将其记录下来,并且使用streamdownload=true
请参阅以下常见问题解答-why-is-my-message-body-empty以及如何使用流缓存。

因为消息是基于流的,所以要么不记录消息正文(您可以记录消息头等),然后将其路由到文件endpoint,以便将其直接保存为文件。

 类似资料:
  • 我正在使用JSCH从SFTP服务器下载文件。我使用单会话,多通道下载文件从不同文件夹位于SFTP。对于这个下载过程,我有一组排定的作业。每项工作将: 每次打开一个新通道()。通道名称:SFTP 使用方法获取要下载的文件总数的大小 如果size(Vector)大于零,则使用下载所有文件 最后关闭打开的通道。 在上面的过程中,大多数时候我得到的文件,找不到或没有这样的文件异常,并没有下载一些文件。 谁

  • 我正在尝试使用JSch从SFTP服务器下载文件到我的本地机器。无论文件大小如何,它只下载16371字节的数据并结束传输。它不会引发任何异常。如果文件小于16371字节,它将成功传输,但对于任何较大的文件,传输都会导致文件损坏。

  • 问题内容: 我的GSP中有这个ajax调用: 这是我的控制器操作的代码块: 我从通过$ .Ajax方法从视图传递的数据中获取票证列表。比我将数据格式化为CSV格式,然后我想将数据导出为CSV文件,但没有任何反应。数据已发送到客户端,但是由于内容配置不正确,因此没有可供下载的文件。我想念什么?我试图做类似的事情: 并在控制器中生成纯字符串,但是那样我得到的文件没有扩展名是不可接受的。 我该如何实现?

  • 问题内容: 我正在使用jsch从服务器下载文件,下面是我的代码。 com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2629) at com.jcraft.jsch.ChannelSftp._get(ChannelSftp.java:977) at com.jcraft.jsch.ChannelSftp.get(Channe

  • 我已经检查了SFTP服务器,它是启动的。

  • 我能够使用canmel路由定义中的以下uri从sftp目录成功下载一个/所有文件: 下载所有文件 下载一个文件 我的要求是下载特定的文件列表= one.text,two.text。 如何将文件名列表传递到骆驼路由?最好是我正在寻找一个解决方案,我可以在其中指定如下内容