0

We are sending hundreds of files every minute to several servers.

Currently we are generating the shell scripts (as files via java) which contains only sftp commands and executing them as shell scripts. The reason why we are using java is to organize the files based on target path and target server. At the end, for each target server we will have one shell script.

Now I am thinking will it be more efficient and fast if I send the files via java code itself instead of generating script and executing it

Currently it takes 4 to 5 seconds to generate the scripts for 4 servers. So the execution of actual sftp starts at 5 th second and finishing very fast (based on files count). If I switch to java sftp like JSch will it be the same fast as sftp in shell script or slower?

Rajeshkumar
  • 815
  • 12
  • 35
  • 1
    There's a lot of ways in which a Java implementation could be faster than a shell implementation. But whether or not it actually will be depends on the implementation of both, so this really isn't an answerable question with a reasonable scope for stackoverflow. My suggestion would be to investigate how much of a problem the current slowness of the process is, investigate how much time a Java implementation is likely going to take, and then if you think the possible gains are worth the effort just do it and see how much of a difference it makes. – Cubic Apr 02 '16 at 09:18
  • Why does it take 4-5 seconds to generate the scripts? That seems like a good place to look for inefficiencies. Can you generate one script and run it before generating the next? – chicks Apr 02 '16 at 14:57

1 Answers1

1

It depends on what do you want to achieve. If maintenance of that solution is also a factor I would suggest using apache-camel with ftp component https://github.com/apache/camel/tree/master/examples/camel-example-ftp . Gives you control and flexibility. No shell scripts generation. And most of all you can write an app (if needed) around it or make it a part of already existing one.

gmaslowski
  • 774
  • 5
  • 13