Question

When you want to launch scripts (.sh,jar,.py,.pl...) running more than some hours by a simple click on a user interface(for example a nice jsf page). What are the best methods to throw process. Running.exec() method , the use of Threads or something else ? Thanks.

Was it helpful?

Solution

Definitely do not use long running threads inside a Java web app. Send a message with the task (ideally via a queue (for example rabbitmq)) to a separate application with its own thread pool, which will then handle independently the long running tasks requested by the webapp users.

If your system does not have a messaging system installed, and you find the overhead of managing one too high, and you are already using some sql or no-sql or whatever storage, you can probably adapt this storage to also be used for communication between the webapp and your new separate long requests runner app.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top