Repository navigation
Cluster ability like in quartz-1.0.2 #2
Description
In Quartz 1.0.2 for Grails 2.x, the Jobs can be clustered over several tomcat instances. For this ability, the Quartz plugin loaded in the QuartzGrailsPlugin.groovy in the "doWithSpring"-method
def doWithSpring = { context ->
def config = loadQuartzConfig(application.config)
///...
}via the "loadQuartzConfig"-method (which now is completely missing!) the following things:
/*
* Load the various configs.
* Order of priority has been "fixed" in 1.0-RC2 to be:
*
* 1. DefaultQuartzConfig is loaded
* 2. App's Config.groovy is loaded in and overwrites anything from DQC
* 3. QuartzConfig is loaded and overwrites anything from DQC or AppConfig
* 4. quartz.properties are loaded into config as quartz._props
*/
private ConfigObject loadQuartzConfig(ConfigObject config) {
def classLoader = new GroovyClassLoader(getClass().classLoader)
String environment = Environment.current.name
// Note here the order of objects when calling merge - merge OVERWRITES values in the target object
// Load default Quartz config as a basis
def newConfig = new ConfigSlurper(environment).parse(classLoader.loadClass('DefaultQuartzConfig'))
// Overwrite defaults with what Config.groovy has supplied, perhaps from external files
newConfig.merge(config)
// Overwrite with contents of QuartzConfig
try {
newConfig.merge(new ConfigSlurper(environment).parse(classLoader.loadClass('QuartzConfig'))) //Which was located in grails-app/conf/
} catch (Exception ignored) {
// ignore, just use the defaults
}
// Now merge our correctly merged DefaultQuartzConfig and QuartzConfig into the main config
config.merge(newConfig)
// And now load quartz properties into main config
def properties = new Properties()
def resource = classLoader.getResourceAsStream("quartz.properties") //Which was located in grails-app/conf/quartz/
if(resource != null) properties.load(resource)
if(config.quartz.containsKey('props')) properties << config.quartz.props.toProperties('org.quartz')
config.quartz._properties = properties
return config.quartz
}The grails-app/conf/quartz/quartz.properties did contain all needed information for the clustering ability:
org.quartz.scheduler.instanceName=app_quartz
org.quartz.scheduler.instanceId=AUTO
org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount=5
org.quartz.threadPool.threadPriority=5
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.tablePrefix=QRTZ_
org.quartz.jobStore.isClustered=true
org.quartz.jobStore.clusterCheckinInterval=1000
org.quartz.plugin.shutdownhook.class=org.quartz.plugins.management.ShutdownHookPlugin
org.quartz.plugin.shutdownhook.cleanShutdown=true With this config information, the plugin persisted all jobs from grails-app/jobs/* into the databse-tables, which were located in the grails-quartz/src/templates/sql/ folder, for setting up the tables in the db for each dbms. I am not sure, which methods beside the above described are needed to be implemented for the clustering features... but all i can say till now is, that the jobs are not persisted in the database till now, even though i put the QuartzConfig.groovy (or the equivalent DefaultQuartzConfig.groovy from grails-quartz/grails-app/conf/ folder) into the application.yml from my grails3 project and set the quartz.jdbcStore = true.
I hope these information is enough (for the moment) to resotre the clustering ability for grails3.
Activity
graemerocher commentedon Mar 9, 2015
@jeffbrown Should still be possible via
application.ymlno?jeffscottbrown commentedon Mar 9, 2015
@graemerocher Yes, still possible. It may be that the plugin isn't loading up those config settings in M2 of the plugin. I will look at it and get it addressed.
dtamm commentedon Mar 9, 2015
@jeffbrown thanks! just ring me up when i shall test a new version!
dtamm commentedon Mar 31, 2015
any updates on this one yet?
jeffscottbrown commentedon Mar 31, 2015
Not yet. It is still in the queue and will get addressed. If anyone is interested in putting a pull request together, that input would be welcomed. Otherwise I will get to it hopefully before too long.
Thanks for the feedback. I appreciate it.
https://github.com/grails3-plugins/quartz/issues/2
robbugh commentedon May 26, 2015
I created a pull request to address this issue. See: #5
Regards,
Rob
dtamm commentedon May 26, 2015
If the pullrequest gets accepted, i will test it out!
dtamm commentedon May 29, 2015
nevermind, i just had some properties wrong, but now i get the error, that the DataSource name is not set:
Merge pull request #5 from robbugh/master
dtamm commentedon May 29, 2015
Okay, i got it fixed and will do a pullrequest later!
dtamm commentedon May 29, 2015
Made a PR #6
dtamm commentedon Jun 2, 2015
For my understandings, this ticket can be closed as fixed... tried myself a grails3 app on 2 tomcats with this plugin, worked!
https://github.com/grails3-plugins/quartz/issues/2
Merge pull request #5 from robbugh/master