java - RAMJobStore Quartz 2.3 中没有属性 isClustered 的 setter

标签 java quartz-scheduler scheduler quartz

我正在 Quartz 2.3.0 中创建一个 Job,我研究了要创建一个 Job 并将其配置为生产中的多实例环境,它具有在 jar 内的 quartz.properties 文件中定义。

这是我的 quartz.properties 文件:

# Default Properties file for use by StdSchedulerFactory
# to create a Quartz Scheduler Instance, if a different
# properties file is not explicitly specified.

org.quartz.scheduler.instanceName: DefaultQuartzScheduler
org.quartz.scheduler.rmi.export: false
org.quartz.scheduler.rmi.proxy: false
org.quartz.scheduler.wrapJobExecutionInUserTransaction: false
org.quartz.scheduler.instanceId: AUTO

org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 10
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true

org.quartz.jobStore.misfireThreshold: 60000

org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore
org.quartz.jobStore.isClustered : true

这些是我的java类TestPlugin:

public class TestPlugin implements PlugIn {
    private static Scheduler scheduler;

    public TestPlugin() {
        super();
    }

    public void destroy() {
    }

    public void init(ActionServlet arg0, ModuleConfig arg1) throws ServletException {
        try {
            JobDetail job = JobBuilder.newJob(TestDemonio.class).withIdentity(new JobKey("jobs", "group1")).build();//.withIdentity("anyJobName", "group1").build();
            Trigger trigger = TriggerBuilder
                    .newTrigger()
                    .withIdentity("anyTriggerName", "group1")
                    .withSchedule(CronScheduleBuilder.cronSchedule("0/59 * * ? * * *"))//0/5 * * * * ?
                    .build();

            Scheduler scheduler = new StdSchedulerFactory().getScheduler();
            scheduler.scheduleJob(job, trigger);
            scheduler.start();
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
}

我的TestDemon类:

@DisallowConcurrentExecution
public class TestDemon implements Job {

    public void execute(JobExecutionContext arg0) throws JobExecutionException {
        try {
            System.out.println("PRINT JOB MESSAGE");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

但是我收到了SchedulerException:

JobStore class 'org.quartz.simpl.RAMJobStore' props could not be configured. [See nested exception: java.lang.NoSuchMethodException: No setter for property 'isClustered']

最佳答案

无法为 RAMJobStore 启用集群,因为quartz-scheduler 使用数据库进行集群,并且在 RAMJobStore 的情况下,作业是在内存中创建的,无法跨进程共享。

Clustering currently works with the JDBC-Jobstore (JobStoreTX or JobStoreCMT) and the TerracottaJobStore. Features include load-balancing and job fail-over (if the JobDetail’s “request recovery” flag is set to true).

http://www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/tutorials/tutorial-lesson-11.html

关于java - RAMJobStore Quartz 2.3 中没有属性 isClustered 的 setter ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57446418/

相关文章:

java - 如何在 Activity 上显示标题栏

java - 如何检查文件是否被另一个程序使用

java - 该多线程代码的计数器输出

java - Dropwizard quartz 作业不适用于 Guicey

java - Struts 2制作动态参数

java - 实现StatefulJob时 "delay"是什么意思?

spring-boot - 使用作业存储 'org.quartz.simpl.RAMJobStore' - 不支持持久性。并且不聚集

c - Kernel Scheduler(Linux) - 任务是函数吗?

asp.net-mvc - 计划每晚构建 msbuild 任务

wpf - 如何将Silverlight项目或控件转换为WPF