Reputation: 183
I want to configure a gateway with Java DSL to read all the files from a FTP server recursively, because they are in different folders.
How can I do it? I´ll apreciate code examples please
Upvotes: 2
Views: 775
Reputation: 121382
Something like this:
@Bean
public FtpOutboundGatewaySpec ftpOutboundGateway() {
return Ftp.outboundGateway(this.ftpSessionFactory,
AbstractRemoteFileOutboundGateway.Command.MGET, "payload")
.options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE)
.regexFileNameFilter("(subFtpSource|.*1.txt)")
.localDirectoryExpression("@ftpServer.targetLocalDirectoryName + #remoteDirectory")
.localFilenameExpression("#remoteFileName.replaceFirst('ftpSource', 'localTarget')");
}
@Bean
public IntegrationFlow ftpMGetFlow(AbstractRemoteFileOutboundGateway<FTPFile> ftpOutboundGateway) {
return f -> f
.handle(ftpOutboundGateway)
.channel(remoteFileOutputChannel());
}
@Bean
public PollableChannel remoteFileOutputChannel() {
return new QueueChannel();
}
The copy/paste from the project's test-cases.
Upvotes: 1