My spring batch project needs to download files from multiple sftp servers. the sftp host/port/filePath is config in application.properties file. I consider using the spring integration 'sftp out-bound gateway' to connect these servers and download files. but Im don't how to do this kind of configuration(I'm using java config, ) and make it work? i guess I need some way to define multiple session factory according to the number of sftp server info config in application.properties file.
properties file:
sftp.host=host1,host2
sftp.user=user1,user2
sftp.pwd=pwd1,pwd2
config class:
@Bean
public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory1() {
...
}
@Bean(name = "myGateway1")
@ServiceActivator(inputChannel = "sftpChannel1")
public MessageHandler handler1() {
...
}
@MessagingGateway
public interface DownloadGateway1 {
@Gateway(requestChannel = "sftpChannel1")
List<File> start(String dir);
}
@Bean(name="sftpChannel1")
public MessageChannel sftpChannel1() {
return new DirectChannel();
}