在JavaEE 6中执行子流程 [英] Execute subprocesses in JavaEE 6

查看:82
本文介绍了在JavaEE 6中执行子流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的应用程序服务器(Glassfish 3.1.2)中执行子流程

I'm trying to execute subprocesses from within my application server (Glassfish 3.1.2)

因此,我发现了Apache Commons Exec库.问题在于此库创建的线程不应在应用程序服务器上完成,因为服务器不知道这些线程.
有什么办法可以解决这个问题?

Therefore I discovered the Apache Commons Exec library. The problem is that this library creates threads which should not be done on an application server because the server is not aware of these threads.
What could be a solution to this problem?

是否可以创建一个用Java SE编写的消息组件,该组件使用包含有关待处理作业信息的消息并在应用程序服务器中注册它?

Would it be possible to create a message component written in Java SE who consumes messages containing information about pending jobs and register it with the application server?

然后,应用服务器将不必处理运行时异常和线程,而只使用包含结果或异常的消息.

The application server would then not have to deal with runtime exceptions and threads but just consume messages which contain the result or an exception.

您有更好的主意吗?

推荐答案

您可以使用:

  • MDB (as pointed by duffymo),
  • Servlets 3.0 asynchronous processing,
  • Asynchronous EJB invocation.

实际上,它应该为您提供与普通子流程类似的功能.

Effectively, it should give you similar functionality as plain subprocesses.

使用Java SE组件与Java EE进行通信只是为了克服自己使用线程的麻烦,这听起来有些过头了.只需阅读提到的解决方案,然后尝试其中的任何一种都符合您的需求即可.

Using Java SE component which communicates with Java EE just to overcome using threads on your own sounds a bit like an overkill. Just read about mentioned solutions and try if any of them fits your needs.

这篇关于在JavaEE 6中执行子流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆