Axis2 中的后台任务 - Tomcat 堆栈

发布于 2024-09-29 02:45:18 字数 490 浏览 0 评论 0原文

我正在开发一个需要提供 SOAP 服务的 Java 服务器端应用程序。为此,我们使用 Axis2 并部署在 Tomcat 6 安装中。

我们有以下问题:我们需要运行几个后台线程;第一个用于定期查询另一个 Web 服务以获取所提供数据的更改,第二个用于监视和使用 MQ 中的数据。

我的问题是,运行这些后台任务的最佳 Java EE 实践是什么?我们是否应该将它们作为后台线程运行,并以某种方式告诉 Tomcat 在启动时运行?有没有比从 Web 应用程序容器生成线程更好的方法?

该系统还不够大,不足以争论将其分解为更小的部分(例如,在系统守护程序中运行后台任务,其中 Web 服务部分是查询该系统守护程序的单独无状态组件)。出于同样的原因,我们无法选择在像 JBoss 这样的完整应用程序服务器中运行(这会有什么区别吗?)。

谢谢!

更新: 关于补充问题,如果我们只是为这些任务生成新线程(并假设这不是常见做法),Tomcat(或 Axis)是否会变得更加不稳定或存在任何其他问题?

I am working on a Java server side application that needs to provide a SOAP service. For this, we are using Axis2 and deploy in a Tomcat 6 installation.

We have the following issue: we need to run a couple of background threads; one to periodically query another web service for changes in provided data and a second one to monitor and consume data in an MQ.

My question is, what is the best, Java EE, practice to run these background tasks? Should we just run those as background threads that we'll somehow need to tell Tomcat to run at startup? Is there a better way than spawning threads from the web app container?

The system is not large enough to argue breaking it to smaller parts (e.g. run the background tasks in a system deamon with the webservice part being a separate stateless component querying that system deamon). For the same reason we do not have the option to run within a full app server like JBoss (would that make any difference?).

Thanks!

UPDATE:
On a supplementary question, if we just spawned new threads for these tasks (and assuming that this is not common practice), would Tomcat (or Axis) be made more unstable or have any other issues?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦年海沫深 2024-10-06 02:45:18

我建议使用 quartz-scheduler 来处理此类事情。它比线程本身更简单,当然使用起来也更灵活。 Tomcat 或 Axis2 启动期间有拦截器,因此您可以在那里启动调度程序。

I would suggest to use quartz-scheduler for such kind of things. It's simpler than to threads itself and of course more flexible to use. There are interceptors during the start of Tomcat or Axis2 so you can start the scheduler there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文