【发布时间】:2021-12-09 19:51:41
【问题描述】:
我有一个项目,我需要从远程 FTP 文件夹中获取 .csv 文件,问题是文件很大,可以说是 6-7 MB,即使尚未从第三个文件夹完全传输,投票也会开始读取它们党,这是一个例外。
我看到我们可以使用 LastModifiedFileListFilter 但不确定这是否是正确的解决方案。
这是我的代码示例。
@Bean
public IntegrationFlow ftpInboundFlow() {
return IntegrationFlows
.from(Ftp.inboundAdapter(ftpSessionFactory())
.preserveTimestamp(true)
.remoteDirectory("/ftp/GE/Inbound")
.patternFilter("*.csv")
.deleteRemoteFiles(true)
.localDirectory(new File("inbound"))
.temporaryFileSuffix(TEMPORARY_FILE_SUFFIX),
e -> e.id("ftpInboundAdapter")
.poller(Pollers.fixedDelay(5000))
.autoStartup(true))
.transform(e -> {
log.info("Sending CSV file " + e + " to FTP server");
return e;
})
.handle(Ftp.outboundAdapter(ftpSessionFactory())
.useTemporaryFileName(true)
.autoCreateDirectory(true)
.remoteDirectory("/ftp/GE/Inbound/history"))
.get();
}
例外:
Caused by: org.springframework.messaging.MessagingException: Failure occurred while copying '/ftp/GE/Inbound/OA_ex_PK_2020_2021.csv' from the remote to the local directory; nested exception is java.io.IOException: Failed to copy '/ftp/GE/Inbound/OA_ex_PK_2020_2021.csv'. Server replied with: 550 The process cannot access the file because it is being used by another process.
【问题讨论】:
标签: spring-integration spring-integration-dsl