Search code examples
javafile-uploadftpapache-commons-netgpars

Uploading files in parallel with Java FTP client


I was using GPars to upload files in a parallel manner with ftp4j client library as:

GParsPool.withPool {
            files.eachParallel { file -> ftpClient.upload(directory, stream)
}

But, now I only have server ELB address for which ftp4j client is not working, so I changed the client to Apache Commons Net FTP client, and this is not thread safe because of which I can't do parallelization.

Is there any other FTP library which supports parallelization and remote verification false (to support elb)??

Or, I need to do something on server side (elb configuration) so that I do not need to change ftp client??


Solution

  • You cannot upload multiple files in parallel over one FTP connection. It does not matter what FTP library are you using and if it is thread safe or not. The protocol itself does not allow that.

    And even if it did (like for example SFTP does), it would not bring you any performance advantage.

    You have to open a separate connection for each thread.