Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 0.3
-
Component/s: None
-
Labels:None
-
Patch Submitted:Yes
Description
I've attached some code that adds support for using a JDBC store instead of the in-memory store. This allows clustered scheduling, where only one cluster instance should be running each task. In addition, it allows persistent job storage between runs, if the user accesses the Quartz scheduler directly and schedules an ad-hoc job (i.e. not defined in a Job class).
The current code doesn't work with JDBC storage because Spring's helper classes aren't serializable, so I've replaced them with simpler versions that have most of the same functionality (100% of what's currently being used in the plugin) and are serializable. I added some configurability via a config file - grails-app/conf/DefaultQuartzConfig.groovy - which is user-overrideable if they create grails-app/conf/QuartzConfig.groovy. This is based on the approach used in the Acegi plugin.
In addition, I added a flag to not start the scheduler at startup. This should help with GRAILSPLUGINS-47 and GRAILSPLUGINS-359, and also during testing. The user can configure the startup in Bootstrap, which isn't run for unit/integration tests:
import org.codehaus.groovy.grails.commons.ApplicationAttributes
class BootStrap {
def init = { servletContext ->
def ctx = servletContext.getAttribute(ApplicationAttributes.APPLICATION_CONTEXT)
ctx.quartzScheduler.start()
}
def destroy = {}
}
By default if the user does nothing the plugin will work as before. To enable JDBC storage the user has to create QuartzConfig.groovy and set jdbcStore to true, and also put a quartz.properties in the classpath and ensure that the required database tables exist. I've attached some Hibernate files that do this automatically if using create-drop.
Burt, I committed your patch in rev. 41075 and rev. 41076 with slight modifications:
Thank you very much for your work!
- added per-environment configuration
- added merging configuration into central Grails configuration (ConfigurationHolder.config)
- moved scheduler startup code into plugin's QuartzBootStrap, so it fixes issues with early startup, but don't require user to write code into BootStrap file
- added InstallQuartzConfig script
- added license info to all files
Thank you very much for your work!