I am using the quartz plugin with Grails 1.3.7. I have a need to load balance/cluster a server app that uses quartz jobs. Apparently this is supported but I am finding that all the google search results and links within documents are broken. I've found some raw Java examples but I would assume Grails has a more grailsy way to do this. All I need is a simple example to use as a template. I understand I need to somehow enable quartz to use JDBC to store the jobs and manage locking.
I think a link to a single sample would do it. But literally every time I've found something that looks promising it points to a broken link on terracotta's site. Pretty much every site eventually leads me here: http://www.opensymphony.com/quartz/wikidocs/TutorialLesson9.html but when I look on terracotta's site I see Java stuff but no grails. If Java is the only way to do this then so be it, but I feel like there has to be some grails expertise on this out there somewhere!
TIA.
To cluster the Quartz plugin in Grails, there are some files you need to include in your project. First, install the
grails-app/conf/QuartzConfig.groovy
and make surejdbcStore
is enabled.Next, install the Hibernate configuration files relevant to the database to which you will be connecting. For example, with Oracle, the base Hibernate xml config at
grails-app/conf/hibernate/hibernate.cfg.xml
is:The actual Quartz-Hibernate SQL file for this example will be named
Quartz.oracle.hbm.xml
and will reside in the same directory. These files should be available at the Quartz plugin on GitHub (https://github.com/nebolsin/grails-quartz), undersrc/templates/sql
. Note, that these scripts only seem to work for DataSourcecreate
andcreate-drop
, so you'll need to manually create the Quartz tables on anupdate
, if they don't already exist from a previous run.Create a
grails-app/conf/quartz/quartz.properties
file, and edit is to fit your business needs:Note from the above properties, you can set
org.quartz.plugins
in the Log4j setup ofConfig.groovy
to log relevant job and trigger triggering information. I thinkinfo
level should suffice.Edit, or create,
scripts/_Events.groovy
and add the following war modification closure. This fixes a known Quartz plugin bug to install the correctquartz.properties
, instead of a blank one from the plugin, in to the final war file.And you should be done...
P.S. If you are using an Oracle database, add the following to
BuildConfig.groovy
in the dependencies block, so that you have access to the Quartz-Oracle communication drivers:P.P.S The sql files at the link above are just the SQL. To make it in to a hibernate file, just surround each individual SQL command with a Hibernate
database-object
node, like so (again w/ Oracle example):The
dialect-scope
tells Hibernate with which Database dialects the create and drop nodes should be used. You can try leaving it out and see if it works, otherwise you may have to add the MySql dialect used by your Grails DataSource.The accepted answer is a bit out-dated. See this question for a simpler solution with more recent versions of Grails: Using grails datasources in quartz plugin