quartz触发器在大多数情况下处于错误状态

brvekthn  于 2021-07-11  发布在  Java
关注(0)|答案(0)|浏览(227)

我为它创建了一个cron作业和配置。有时它工作正常(应用程序运行后,调度程序工作正常)。但在大多数情况下(应用程序运行后)触发器处于错误状态。。。什么原因?我读过文档,用不同的方式配置,但是没有成功。。。。
请提供支持。
我的职业类别:

public class MyJob implements Job {

    private static final Logger LOGGER = getLogger(MyJob.class);
    private final SessionFactory sessionFactory;

    @Inject
    public MyJob(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

    @Override
    public void execute(JobExecutionContext context) {
        System.out.println("Test");
    }
}

配置:

private void scheduleCronJob(Class<? extends Job> jobClass, String cronSchedule) {
        try {
            var jobKey = new JobKey(formatId(jobClass, cronSchedule));
            if (scheduler.checkExists(jobKey)) {
                return;
            }

            var job =
                    newJob(jobClass)
                            .withIdentity(jobKey)
                            .build();

            var trigger =
                    newTrigger()
                            .withIdentity(formatId(jobClass, cronSchedule))
                            .withSchedule(cronSchedule(cronSchedule))
                            .build();

            scheduler.scheduleJob(job, trigger);
        } catch (SchedulerException e) {

        }
    }

我在conf.yml中的conf

jobs:
  com.myTestProject.jobs.MyJob: "0 0/5 * * * ? *"

   org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
    org.quartz.threadPool.threadCount: 20
    org.quartz.threadPool.threadPriority: 7
    org.quartz.scheduler.skipUpdateCheck: true
    org.quartz.jobStore.misfireThreshold: 120000
    org.quartz.jobStore.class: org.quartz.impl.jdbcjobstore.JobStoreTX
    org.quartz.jobStore.useProperties: false
    org.quartz.jobStore.tablePrefix: "P_QRTZ_"
    org.quartz.jobStore.isClustered: true
    org.quartz.jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate

我被困了很久。。。谢谢!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题