Using grails datasources in quartz plugin

跟風遠走 提交于 2019-12-03 20:33:21

I managed to tweak all my settings in QuartzConfig.groovy. The only thing I had to remove to make it work were the database specific options.

Also, I had to add the property scheduler.idleWaitTime = 1000 as advised here http://www.quartz-scheduler.org/generated/2.2.1/pdf/Quartz_Scheduler_Configuration_Guide.pdf on page 12, because despite my job being called as MyJob.triggerNow(paramsMap), there was a 20 to 30 seconds delay before it actually started.

With scheduler.idleWaitTime set to 1 second, the job indeed triggers 1 second after it has been submitted.

QuartzProperties.groovy actually accepts all the properties described in the quartz configuration docs (e.g. : http://quartz-scheduler.org/documentation/quartz-2.1.x/configuration/ConfigJobStoreTX). Just put them inside the props {...} block, and remove the org.quartz prefix.

Here is my final config, as an example :

quartz {
    autoStartup = true
    jdbcStore = true
    waitForJobsToCompleteOnShutdown = true

   // Allows monitoring in Java Melody (if you have the java melody plugin installed in your grails app)
   exposeSchedulerInRepository = true

    props {
        scheduler.skipUpdateCheck = true
        scheduler.instanceName = 'my_reporting_quartz'
        scheduler.instanceId = 'AUTO'
        scheduler.idleWaitTime = 1000

        threadPool.'class' = 'org.quartz.simpl.SimpleThreadPool'
        threadPool.threadCount = 10
        threadPool.threadPriority = 7

        jobStore.misfireThreshold = 60000

        jobStore.'class' = 'org.quartz.impl.jdbcjobstore.JobStoreTX'
        jobStore.driverDelegateClass = 'org.quartz.impl.jdbcjobstore.StdJDBCDelegate'

        jobStore.useProperties = false
        jobStore.tablePrefix = 'QRTZ_'
        jobStore.isClustered = true
        jobStore.clusterCheckinInterval = 5000

        plugin.shutdownhook.'class' = 'org.quartz.plugins.management.ShutdownHookPlugin'
        plugin.shutdownhook.cleanShutdown = true

    }
}

Don't forget to create the sql tables with the appropriate script, which is located at /path/to/your/project/target/work/plugins/quartz-1.0.2/src/templates/sql/...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!