I am using Spring Integration version 5.4.4 in a Spring Boot application. I need to get all the XML files from subdirectories under the "server_sftp" directory. For this I use SFTP Streaming Inbound Channel Adapter and SFTP Outbound Gateway with mget command. Unfortunately, the application only downloads files from the root directory ("server_sftp"), and does not download files from subdirectories.
Where do I go wrong?
@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();
}