调用从Web服务器异步应用程序

调用从Web服务器异步应用程序

问题描述:

我与Tomcat上运行的春天做了一个Web应用程序。在同一台机器上有一个正常的Java应用程序。

I have a web application made with Spring that runs on Tomcat. On the same machine there is a normal Java application.

我想从Web服务器调用它来执行Java应用程序,但我想使它所以应用程序将无法使用服务器的资源(它涉及一个分类的培训,因此它可能占用大量的资源和时间),它不能挂在服务器(所以它必须被异步调用)。

I would like to execute the Java application by calling it from the web server, but i want to make it so the application won't use the server's resources (it involves the training of a classifier so it may take up a lot of resources and time) and it must not hang the server (so it must be called asynchronously).

有没有办法做到这一点?

Is there any way to do that?

您有两种选择。


  1. 通过执行 EXEC ,并使用的Java 命令来启动一个单独的JVM实例。

  1. Start a separate JVM instance by doing a exec and using a java command.

生成一个新的线程 - 这将使用服务器的资源虽然

Spawn a new thread - this will use server's resources though.

您还可以结合选项1和2以及创建一个线程,做了 EXEC 电话。

You can also combine options 1 and 2 and create a thread that does the exec call.