문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top