要求是定期运行Java应用程序(例如,每天运行一个示例)以向客户发送电子邮件/ SMS通知。环境是群集/高可用性,其中多个节点将同时处于活动状态。该应用程序将部署在所有节点上,但是即使所有节点都配置为运行,也只能启动和运行该应用程序。如何实现这一目标。在Java应用程序中,使用了Quartz Scheduler。

还需要一些有关如何在Linux机器上部署此Java应用程序的指南(例如Cron作业或其他方式)。要求是该应用程序应在服务器系统启动时启动,并将永远运行直到服务器关闭。当服务器再次启动时,该作业也应自动启动。

最佳答案

The requirement is to run a java application periodically (say everyday for an example) to send out email/SMS notification to customers.


Quartz可以通过创建一个Job和将在特定时间触发的触发器来实现这一点。

The environment is cluster / high availability where more than one node will be active at the same time. This application is to be deployed on all the nodes but only one should start and run even though all of them are configured to run. How to achieve this


Quartz调度程序通过数据库支持集群机制。如果两个或多个调度程序具有相同的名称但实例ID不同,则它们将组成集群,但要注意的是,所有应用程序节点都应指向同一数据库。

Also need some guidance on how to deploy this java application on Linux machine (like Cron job or some other way).


当Quartz执行调度工作时,无需创建linux cron作业。

When the server starts again, this job should also start automatically.


Quartz可以处理未触发的触发器,因此,如果应用程序关闭,Quartz将在应用程序启动时扫描未触发的触发器并安排它们。

为了使上述功能正常工作,您应该在石英中使用JDBC Jobstore而不是RAMJobStore

关于java - 每天在集群环境中运行Quartz Scheduler,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56137512/

10-13 01:20