【发布时间】:2021-06-06 21:12:29
【问题描述】:
我在 Spring Boot 应用程序中使用 Spring Integration 5.4.4 版。 我需要从“server_sftp”目录下的子目录中获取所有 XML 文件。为此,我使用带有 mget 命令的 SFTP Streaming Inbound Channel Adapter 和 SFTP Outbound Gateway。不幸的是,该应用程序仅从根目录(“server_sftp”)下载文件,而不从子目录下载文件。
我哪里出错了?
@Bean
@InboundChannelAdapter(channel = "downloadXmlFileInputChannel", poller = @Poller(fixedDelay = "300000"))
public MessageSource<InputStream> sftpXmlFileMessageSource() {
SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template());
messageSource.setRemoteDirectory("server_sftp/");
return messageSource;
}
@Bean
public IntegrationFlow xmlFilesReadingFlow() {
return IntegrationFlows
.from(sftpXmlFileMessageSource(), e -> e.poller(Pollers.fixedDelay(Duration.ofSeconds(5))))
.handle(Sftp
.outboundGateway(template(), Command.MGET, "'server_sftp/*'")
.options(Option.RECURSIVE)
.autoCreateLocalDirectory(true)
.localDirectoryExpression("'../webapps/event_report_app-1.0/xmlFilesLocalDirectory/' + #remoteDirectory")
.localFilenameExpression("#remoteFileName.replaceFirst('sftpSource', 'localTarget')"))
.channel("downloadXmlFileOutputChannel")
.get();
}
@Bean
public PollableChannel downloadXmlFileInputChannel() {
return new QueueChannel();
}
@Bean
public DirectChannel downloadXmlFileOutputChannel() {
return new DirectChannel();
}
【问题讨论】:
标签: spring-integration spring-integration-sftp