Linked Questions

Popular Questions

How to configure multiple gateways in Spring Integration?

Asked by At

Handling Multiple-SFTP Hosts in Spring Integration

I want to configure multiple SFTP hosts so based on user input (user passing hostName), I will select the HOST and perform read operation.

The issue is I don't wanna create multiple Java files. instead, I wanna input the host details as an array in properties files and based on that input, the configuration create 1, 2 or more SessionFactories, Gateways and etc.

Following is the configuration that I used to setup single Host.....

public class HostConfiguration {

  public SessionFactory<LsEntry> sftpSessionFactory() {

    DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);

    return new CachingSessionFactory<LsEntry>(factory);

  @ServiceActivator(inputChannel = "toSftpReadChannel")
  @Description("Sftp Outbound Gateway for SFTP Read Operation")
  public MessageHandler sftpReadHandler() {

    SftpOutboundGateway sftpReadGateway = new SftpOutboundGatewaysftpSessionFactory(), Command.LS.getCommand(), "payload");

    return sftpReadGateway;

  @Bean(name = PollerMetadata.DEFAULT_POLLER)
  public PollerMetadata poller() {
   return Pollers.fixedRate(500).get();

  @Description("Sftp Read Request Channel")
  public MessageChannel toSftpReadChannel(){
    return new QueueChannel(5);

  @Description("Sftp Read Response Channel")
  public MessageChannel fromSftpReadChannel(){
    return new DirectChannel();

  public interface SftpGateway {

    @Gateway(requestChannel = "toSftpReadChannel", replyChannel = "fromSftpReadChannel")
    Future<Message> readFromRemoteSftp(Message message);



Any idea how to achieve this in Spring-Boot/Spring-Integration!!!!

Related Questions