grails - 如何在grails 3中配置quartz插件?

标签 grails quartz-scheduler grails3.2.0

最近我尝试配置我的 grails 应用程序以与quartz 调度程序一起使用。不幸的是我配置 JDBC 作业存储失败。 quartz 插件似乎忽略了 quartz.properties 文件,其中表前缀定义为 Z_STAFF_SCHEDULER 。应用程序启动失败并出现异常:

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]]

以下是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"]

这是我在 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

有谁可以帮助我吗?

我正在使用 grails 3.2.3 和quartz 插件 2.0.9

最佳答案

我终于自己找到了解决方案。 quartz 插件的每个选项都可以在 application.yml 本身中配置。请参阅http://www.quartz-scheduler.org/documentation/quartz-2.2.x/configuration/了解支持的参数列表。

您不需要任何其他文件。以下是我的 application.yml 的摘录作为示例:

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'

关于grails - 如何在grails 3中配置quartz插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41331255/

相关文章:

grails - 注册自定义约束

grails - Grails,从gsp到Controller的参数

grails - grails列表在g:sortableColumn中即使没有指定最大/偏移也不返回全部

java - Quartz cron 计划未触发,预计每小时运行一次

grails - 如何在另一个作业完成时触发作业?

ubuntu - 无法在 Tomcat 7 和 Ubuntu 中部署 grails 3 war - 404 错误

java - Grails:Excel 导出 .xlsx 样式问题,打开文件时出现错误消息

grails - Grails插件版本不兼容警告

java - 什么是 quartz 默认线程数

Grails 升级到 3.2 使用配置类型 requestmap 破坏了 springsecurity