Varaj Vignesh
Varaj Vignesh

Reputation: 341

Grails - using config value for cron expression in scheduled jobs

grailsApplication.config.myJob.cron.cronExpression = Configuration.findByConfigKey("schedule")?.configValue

MyJob.schedule(grailsApplication.config.archiveTablesJob.cron.cronExpression)

Bootstrap error...java.lang.RuntimeException.

Its not getting the value from config

How to get the cron value from a table(database) dynamically?

Upvotes: 0

Views: 368

Answers (1)

Dipak Thoke
Dipak Thoke

Reputation: 1983

In your Bootstrap.groovy file set up like this.

import com.Myjob          //import your job package
class BootStrap {

    def grailsApplication

    def init = { servletContext ->
    grailsApplication.config.myJob.cron.cronExpression =        Configuration.findByConfigKey("schedule")?.configValue
        MyJob.schedule(grailsApplication.config.myJob.cron.cronExpression)
    }
}

Upvotes: 1

Related Questions