Quartz Scheduler作业未存储在提供的数据库中

时间:2019-04-18 19:54:01

标签: spring quartz

Quartz正在按预期调度作业,但未在我提供的数据库的任何石英表中创建条目。但是,如果删除所有石英表并尝试启动服务器,它将在提供的数据库中查找表。

这意味着每次内存DB都被使用。 我想使用提供的数据库的原因是能够在应用服务器重启后继续执行作业。 我正在安排要每分钟运行的作业。 我的问题是我不知道自己在做什么错

Spring XML:

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="quartzProperties">
        <map>
            <entry key="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool" />
            <entry key="org.quartz.threadPool.threadCount" value="2" />
            <entry key="org.quartz.jobStore.isClustered" value="false" />
            <entry key="org.quartz.scheduler.jobFactory.class" value="org.quartz.simpl.SimpleJobFactory" />
            <entry key="org.quartz.jobStore.class" value="org.quartz.impl.jdbcjobstore.JobStoreTX" />
            <entry key="org.quartz.jobStore.driverDelegateClass" value="org.quartz.impl.jdbcjobstore.StdJDBCDelegate" />
            <entry key="org.quartz.jobStore.tablePrefix" value="QRTZ_" />
            <entry key="org.quartz.jobStore.dataSource"  value="myDS" />
            <entry key="org.quartz.dataSource.myDS.driver" value="com.mysql.jdbc.Driver"/>
            <entry key="org.quartz.dataSource.myDS.URL" value="jdbc:mysql://localhost:3306/quartz_demo"/>
            <entry key="org.quartz.dataSource.myDS.user" value="root"/>
            <entry key="org.quartz.dataSource.myDS.password" value="root"/>
            <entry key="org.quartz.dataSource.myDS.maxConnections" value="5"/>
        </map>
    </property>
</bean>

其他控制器:

private JobDetail buildJobDetail() {
    return JobBuilder.newJob(ExploderLoopSchedulerJob.class)
            .withIdentity("exploderLoopJob", "exploderLoop-jobs")
            .withDescription("Send Exploder Loop Job")
            .storeDurably()
            .build();
}

private Trigger buildJobTrigger(JobDetail jobDetail, ZonedDateTime startAt) {
    return TriggerBuilder.newTrigger().
            forJob(jobDetail)
            .withIdentity(jobDetail.getKey().getName(), "exploderLoop-triggers")
            .withDescription("Send Exploder Loop Trigger")
            .startAt(Date.from(startAt.toInstant()))
            .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInMinutes(1).repeatForever())
            .build();
}

预期结果是在计划作业上的crystal_triggers中输入。 实际结果是未在任何quartz_表中输入任何内容,并使用In memory DB

0 个答案:

没有答案