title: SFTP Default Session Factory or SFTP Plain connection to upload file to multiple remote servers
body: <p>I do have multiple remote servers configured in our application based on the customers.</p>
  
  <p>When report is ready for that particular customer I should connect to remote server of that particular customer and I should upload the report file.</p>
  
  <p>There are two options in front of me
  a) using Spring's default session factory (getting session factory for every file upload)</p>
  
  <pre><code>    public SessionFactory&lt;LsEntry&gt; sftpSessionFactory() {
          DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
          factory.setHost(sftpHost);
          factory.setPort(sftpPort);
          factory.setUser(sftpUser);
          if (sftpPrivateKey != null) {
              factory.setPrivateKey(sftpPrivateKey);
              factory.setPrivateKeyPassphrase(sftpPrivateKeyPassphrase);
          } else {
              factory.setPassword(sftpPasword);
          }
          factory.setAllowUnknownKeys(true);
          return factory;
      }
  
      @Bean
      @ServiceActivator(inputChannel = "toSftpChannel")
      public MessageHandler handler() {
          SftpMessageHandler handler = new SftpMessageHandler(sftpSessionFactory());
          handler.setRemoteDirectoryExpression(new LiteralExpression(sftpRemoteDirectory));
          handler.setFileNameGenerator(new FileNameGenerator() {
              @Override
              public String generateFileName(Message&lt;?&gt; message) {
                  if (message.getPayload() instanceof File) {
                      return ((File) message.getPayload()).getName();
                  } else {
                      throw new IllegalArgumentException("File expected as payload.");
                  }
              }
          });
          return handler;
      }
  </code></pre>
  
  <p>b) using plain sftp connection </p>
  
  <pre><code> try {
          JSch jsch = new JSch();
          Session session = jsch.getSession("sftpuser", "sftphost");
          session.setPassword("sftppassword");
          java.util.Properties config = new java.util.Properties();
          config.put("StrictHostKeyChecking", "no");
          config.put("PreferredAuthentications",
                  "publickey,keyboard-interactive,password");
  
          session.setConfig(config);
          session.connect();
          Channel channel = session.openChannel("sftp");
          channel.connect();
          System.out.println("sftp channel opened and connected.");
          ChannelSftp channelSftp = (ChannelSftp) channel;
  </code></pre>
  
  <p>which one is more suitable in this use case ?</p>