2

Recently I tried configuring my grails app for use with quartz scheduler. Unfortunately I failed configuring JDBC job store. The quartz plugin seems to ignore quartz.properties file, where table prefix is defined as Z_STAFF_SCHEDULER. Application startup fails with exception:

Caused by: org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Table 'testing.qrtz_locks' doesn't exist [See nested exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'testing.qrtz_locks' doesn't exist]]

Here is the relevant code in application.groovy:

quartz {
    autoStartup = true
    jdbcStore = true
    waitForJobsToCompleteOnShutdown = true
    exposeSchedulerInRepository = false

    props {
        scheduler.skipUpdateCheck = true
    }

}

environments {
    test {
        quartz {
            jdbcStore = false
            autoStartup = false
        }
    }
}


grails.config.locations = ["classpath:conf/quartz.properties"]

and this is my config in quartz.properties:

#============================================================================
# Configure Main Scheduler Properties
#============================================================================

org.quartz.scheduler.instanceName = StaffScheduler
org.quartz.scheduler.instanceId = AUTO

#============================================================================
# Configure ThreadPool
#============================================================================

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 25
org.quartz.threadPool.threadPriority = 5

#============================================================================
# Configure JobStore
#============================================================================

org.quartz.jobStore.misfireThreshold = 60000

org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties = false
org.quartz.jobStore.dataSource = development
org.quartz.jobStore.tablePrefix = Z_STAFF_SCHEDULER_

org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000

#============================================================================
# Configure Datasources
#============================================================================


org.quartz.dataSource.development.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.development.URL = jdbc:mysql://localhost:3306/testing?useSSL=false
org.quartz.dataSource.development.user = testing
org.quartz.dataSource.development.password = nopass
org.quartz.dataSource.development.maxConnections = 10
org.quartz.dataSource.development.validationQuery = select 1

Anyone out there who can help me please?

I'm using grails 3.2.3 and quartz plugin 2.0.9

feuernurmitm
  • 312
  • 2
  • 11

1 Answers1

5

I finally found the solution myself. Every option for the quartz plugin can be configured in application.yml itself. See http://www.quartz-scheduler.org/documentation/quartz-2.2.x/configuration/ for a list of supported parameters.

You do not need any further files. Here's an extract from my application.yml as an example:

quartz:
  autoStartup: true
  jdbcStore: true
  scheduler:
    instanceName: 'staff_scheduler'
    instanceId: 'AUTO'
  threadPool:
    class: 'org.quartz.simpl.SimpleThreadPool'
    threadCount: 25
    threadPriority: 5
  jobStore:
    misfireThreshold: 60000
    class: 'org.quartz.impl.jdbcjobstore.JobStoreTX'
    driverDelegateClass: 'org.quartz.impl.jdbcjobstore.StdJDBCDelegate'
    useProperties: false
    dataSource: 'development'
    tablePrefix: 'Z_STAFF_SCHEDULER_'
    isClustered: true
    clusterCheckinInterval: 20000
  dataSource:
    development:
      driver: 'com.mysql.jdbc.Driver'
      URL: 'jdbc:mysql://localhost:3306/testing?useSSL=false'
      user: 'testing'
      password: 'nopass'
      maxConnections: 28
      validationQuery: 'select 1'
feuernurmitm
  • 312
  • 2
  • 11
  • I use your config but , 2017-07-07 16:39:18.602 ERROR org.springframework.boot.SpringApplication.reportFailure - Application startup failed org.quartz.JobPersistenceException: Couldn't obtain job names: Table 'dev_erp2_db.z_staff_scheduler_job_details' doesn't exist – Denny Jul 07 '17 at 09:44
  • @denny You need to create the database schema for quartz first. Unfortunately the plugin does not do that for you itself. You can find an sql script here: https://github.com/elventear/quartz-scheduler/blob/master/distribution/src/main/assembly/root/docs/dbTables/tables_mysql.sql – feuernurmitm Jul 17 '17 at 20:50
  • @Fmeuer, useful info, any idea what happens if you don't specify some properties? e.g. I only want to up the threadCount & keep using SimpleThreadPool, do you know if you can just specify the threadCount in the threadPool section & leave everything else? – Mike W Nov 28 '17 at 14:18