nebolsin / grails-quartz

This project provides integration of the Quartz scheduling framework into the Grails Framework
http://grails.org/plugin/quartz
61 stars 21 forks source link

Plugin removing triggers on grails startup when using DB persistence #15

Closed tedstevko closed 13 years ago

tedstevko commented 13 years ago

I'm encountering the following problem: I've got a grails app, with the quartz plugin, and a persistent storage (Oracle). My job class has an empty triggers block like so:

class VodServerJob {
    static triggers = {}
    def volatility = false;
    def durability = true;
    def concurrency = false;
    def group = "MyGroup"
    def execute(context) { }
}

,...but I programatically add the triggers as I go along (letting the user schedule kick-off times for a job). When I shut down the app, the triggers are still in the database. But on startup, the triggers are removed, defeating the point of persistent storage.

My config is as follows:

quartz {
    autoStartup = true
    jdbcStore = true
    waitForJobsToCompleteOnShutdown = true
}

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

and my properties are as follows:

#============================================================================
# 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.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
org.quartz.jobStore.useProperties = false
org.quartz.jobStore.dataSource = myDS
org.quartz.jobStore.tablePrefix = QRTZ_

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

org.quartz.dataSource.myDS.driver = oracle.jdbc.driver.OracleDriver
org.quartz.dataSource.myDS.URL = jdbc:oracle:thin:@172.27.5.18:1521:dcrm
org.quartz.dataSource.myDS.user = <hidden, but valid>
org.quartz.dataSource.myDS.password = <hidden, but valid>
org.quartz.dataSource.myDS.maxConnections = 5
org.quartz.dataSource.myDS.validationQuery=select 0 from dual

According to everything I can see, this should allow for DB persistence, and yet, it's getting removed on startup.

tedstevko commented 13 years ago

Found the problem. Make sure that if you're creating triggers, you set them to non-volatile:

trigger.setVolatility(false)