Search code examples
databaseschedulingquartz-schedulerapache-cocoon

How do I configure cocoon to use a database as a store for quartz jobs and triggers


I'm using Cocoon and want to store the jobs and triggers for the quartz scheduler in the database so they are persisted. I can see where I need to make the change in cocoon.xconf but I can't find much on how to configure the datasource etc.

How do I configure this to use our existing (postgres) database?


Solution

  • You need to do 2 things:

    • Add the following configuration to quartz.properties with appropriate values substituted for the $ placeholders

    org.quartz.jobStore.dataSource=myDS
    org.quartz.dataSource.myDS.URL=$URL
    org.quartz.dataSource.myDS.driver=$driver
    org.quartz.dataSource.myDS.maxConnections=5
    org.quartz.dataSource.myDS.password=$password
    org.quartz.dataSource.myDS.user=$user
    org.quartz.dataSource.myDS.validationQuery=$any query that doesn't return an error when properly connected
    org.quartz.jobStore.tablePrefix=QREPL_
    org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
    

    • Create the database tables in which Quartz stores the job data - you should find a DDL script included in the Quartz distribution that will create them for you. Each of the Quartz table names should begins with the same prefix. In the configuration above, I've assumed this prefix is "QREPL_"

    Hope this helps, Don