我想从部署在 Websphere 6.1 集群环境中的 Web 应用程序的某个时间间隔运行后台任务。该任务将访问数据库、发送电子邮件并写入数据库。
我正在考虑在首次加载 Web 应用程序时启动一个线程,如下所示:Background Thread for a Tomcat servlet app .
由于它是一个集群环境,不让任务在集群的每个单独节点上运行的最佳方法是什么?
最佳答案
看看 WAS Scheduler service .
它说集群环境:
Scheduler daemons in a cluster
When multiple schedulers are configured to use the same tables (as is the case in a clustered environment), any of the daemons can find a task and set the alarm in its Java virtual machine (JVM). The task is executed in the virtual machine where the scheduler daemon first runs, until the daemon is stopped and another daemon starts. If an application on server1 schedules a task to run and server2 was started before server1, then the task runs on server2.
关于java - Websphere 6.1集群环境下如何运行定时任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3312386/