Quartz Plugin
  1. Quartz Plugin
  2. GPQUARTZ-100

Cannot override quartz config externally

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-RC
    • Fix Version/s: 1.0-RC
    • Labels:
      None

      Description

      Currently you cannot override quartz config with an external file (as you can with normal grails config), if, for example, you wanted to run quartz on one server and not another.

      This is due to the way the config is merged. In QuartzGrailsPlugin, the application config is loaded first and then has the DefaultQuartzConfig merged into it and then your own QuartzConfig merged (if it exists):

      QuartzGrailsPlugin.groovy
      private ConfigObject loadQuartzConfig() {
              def config = ConfigurationHolder.config
              def classLoader = new GroovyClassLoader(getClass().classLoader)
      
              // merging default Quartz config into main application config
              config.merge(new ConfigSlurper(GrailsUtil.environment).parse(classLoader.loadClass('DefaultQuartzConfig')))
      
              // merging user-defined Quartz config into main application config if provided
              try {
                  config.merge(new ConfigSlurper(GrailsUtil.environment).parse(classLoader.loadClass('QuartzConfig')))
              } catch (Exception ignored) {
                  // ignore, just use the defaults
              }
      ...
      }
      

      If this was reversed (i.e the application config was merged last) then this problem would be fixed.

        Activity

        Hide
        James Cook added a comment -

        There is a workaround, but it's fairly nasty - define your own DefaultQuartzConfig in your grails-app/config folder to look like this:

        DefaultQuartzConfig.groovy
        quartz {
            autoStartup = org.codehaus.groovy.grails.commons.ConfigurationHolder.config.quartz.autoStartup
            jdbcStore = false
            waitForJobsToCompleteOnShutdown = true
        }
        
        environments {
            test {
                quartz {
                    autoStartup = false
                }
            }
        }
        
        Show
        James Cook added a comment - There is a workaround, but it's fairly nasty - define your own DefaultQuartzConfig in your grails-app/config folder to look like this: DefaultQuartzConfig.groovy quartz { autoStartup = org.codehaus.groovy.grails.commons.ConfigurationHolder.config.quartz.autoStartup jdbcStore = false waitForJobsToCompleteOnShutdown = true } environments { test { quartz { autoStartup = false } } }
        Hide
        Mihai Glonț added a comment -

        Thanks for tackling this in Quartz 1.0-RC. Would you be able to include the application's plugins in the list of places where you check for configurations for the scheduler? My application uses Weceem http://grails.org/plugin/weceem and its QuartzConfig is ignored.

        Show
        Mihai Glonț added a comment - Thanks for tackling this in Quartz 1.0-RC. Would you be able to include the application's plugins in the list of places where you check for configurations for the scheduler? My application uses Weceem http://grails.org/plugin/weceem and its QuartzConfig is ignored.

          People

          • Assignee:
            Sergey Nebolsin
            Reporter:
            James Cook
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: