仅在一个WebLogic群集节点上运行@Scheduled任务? [英] Run @Scheduled task only on one WebLogic cluster node?
问题描述
我们正在运行一个Spring 3.0.x Web应用程序(.war),它在群集的WebLogic 10.3.4环境中每夜都有@Scheduled作业.但是,由于将应用程序部署到每个节点(使用AdminServer的Web控制台中的部署向导),该作业每天晚上在每个节点上启动,因此可以同时运行多次.
We are running a Spring 3.0.x web application (.war) with a nightly @Scheduled job in a clustered WebLogic 10.3.4 environment. However, as the application is deployed to each node (using the deployment wizard in the AdminServer's web console), the job is started on each node every night thus running multiple times concurrently.
我们如何防止这种情况发生?
我知道像Quartz这样的库允许通过数据库锁定表来在集群环境中协调作业,甚至我自己也可以实现这样的事情.但是由于这似乎是一个相当普遍的情况,所以我想知道Spring是否还没有一个选项,可以轻松地解决这个问题,而不必向我的项目中添加新的库或手动进行解决.
I know that libraries like Quartz allow coordinating jobs inside clustered environment by means of a database lock table or I could even implement something like this myself. But since this seems to be a fairly common scenario I wonder if Spring does not already come with an option how to easily circumvent this problem without having to add new libraries to my project or putting in manual workarounds.
- 我们无法使用配置文件如果有任何未解决的问题,请告诉我.我还在
Please let me know if there are any open questions. I also asked this question on the Spring Community forums. Thanks a lot for your help.
推荐答案
我们正在使用应用程序数据库内的共享锁表来实现自己的同步逻辑.这样,所有群集节点都可以在实际启动作业之前检查作业是否已经在运行.
We are implementing our own synchronization logic using a shared lock table inside the application database. This allows all cluster nodes to check if a job is already running before actually starting it itself.
这篇关于仅在一个WebLogic群集节点上运行@Scheduled任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!