简体   繁体   English

每天在集群环境中运行Quartz Scheduler

[英]Running Quartz Scheduler Daily on Cluster Environment

The requirement is to run a java application periodically (say everyday for an example) to send out email/SMS notification to customers. 要求是定期运行Java应用程序(例如,每天运行一个示例),以向客户发送电子邮件/ SMS通知。 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. 如何实现这一目标。 In teh Java application, Quartz Scheduler is used. 在Java应用程序中,使用了Quartz Scheduler。

Also need some guidance on how to deploy this java application on Linux machine (like Cron job or some other way). 还需要一些有关如何在Linux机器上部署此Java应用程序的指南(例如Cron作业或其他方式)。 The requirement is that this application should start whever the server system starts and will run forever until the server goes down. 要求是该应用程序应在服务器系统启动时启动,并且将永久运行直到服务器关闭。 When the server starts again, this job should also start automatically. 当服务器再次启动时,该作业也应自动启动。

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

This can be achieved by Quartz by creating a Job and corresponding trigger which will fire at particular time. 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 scheduler supports the clustering mechanism via database.If two or more schedulers have same name but different instance id they will form the cluster,only caveat is that all application nodes should point to the same database. Quartz调度程序通过数据库支持集群机制。如果两个或多个调度程序具有相同的名称但实例ID不同,则它们将组成集群,唯一的警告是所有应用程序节点都应指向同一数据库。

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

When Quartz is doing the work of scheduling there is no need to create a linux cron job. 当Quartz执行调度工作时,无需创建linux cron作业。

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

Quartz has provision to handle the misfired triggers so if an application goes down ,quartz will scan the miss fired triggers on start up of application and schedule them. Quartz可以处理未触发的触发器,因此,如果应用程序关闭,Quartz将在应用程序启动时扫描未触发的触发器并安排它们。

For getting the above things to work you should use JDBC Jobstore in quartz instead of RAMJobStore 为了使上述功能正常工作,您应该在石英中使用JDBC Jobstore而不是RAMJobStore

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM