使用集群在 JBoss 上调度任务
我需要能够为在 JBoss 4.2 上运行的 EJB 应用程序运行一些计划任务(报告)。
在我的初始实现中,我在关联的 WAR 中使用 servlet 从属性文件中读取一些配置,然后使用计时器服务 API 重置计划任务。这可行,但在 Web 项目中关闭初始化似乎有点尴尬。另外,我不确定当应用程序部署在集群环境中时这是否会按预期工作。
完成此类任务的最佳实践是什么?我是否应该使用计时器服务以外的其他东西,是否有更好的方法在服务器启动时初始化计时器?
I need to be able to run some scheduled tasks (reports) for an EJB application running on JBoss 4.2.
In my initial implementation I am using a servlet in an associated WAR to read some configuration from a properties file and then reset the scheduled tasks using the Timer Service API. This works but it seems a bit awkward to have the initialization off in a web project. Also I'm not sure if this will work as expected when the app is deployed in a clustered environment.
What are the best practice for accomplishing this type of task? Should I be using something other than Timer Service and is there a better way to initialize the timers when the server starts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许看看Quartz Scheduler。引用其网站:
我过去曾使用它来触发 EJB 作业,整个解决方案运行良好,具有非常好的可扩展性。要将其与 EJB 一起使用,您需要使用 JobStoreCMT存储调度信息(作业、触发器和日历)。要调整作业执行的资源,请查看配置线程池设置 文档。然后,如果 EJB 部署在集群上,则只需让 EJB 客户端完成其在不同实例上负载平衡请求的工作即可。
Quartz 本身也可以集群,以通过以下方式获得高可用性和可扩展性:如果需要,可以进行故障转移和负载平衡。
关于您提到的属性文件,我不确定您需要准确读取哪种数据,但是,如果没有 servlet,如果您需要读取某些内容,则必须从数据库中读取它。
Maybe have a look at Quartz Scheduler. Quoting its website:
I've used it in the past to trigger EJB jobs and the whole solution was working very well, with very good scalability. To use it with EJB, you'll need to use the JobStoreCMT to store scheduling information (job, triggers and calendars). To tune resources for jobs execution, have a look at the Configure ThreadPool Settings doc. Then, just let the EJB client do its job to load balance requests over the different instances if EJBs are deployed on a cluster.
Quartz itself can also be clustered to get both high availability and scalability through fail-over and load balancing if required.
Regarding the properties file you mentioned, I'm not sure of what kind of data you need to read exactly but, without a servlet, if you need to read something, you'll have to read it from the database.