config.groovy-->
Query
{
Map{
time.'Tue Dec 30 14:48:00 EST 2014' = ['T1']
time.'Wed Dec 30 14:44:00 EST 2014' = ['T2']
templates.'T1' = ['P1','P2','P3']
templates.'T2' = ['Table']
}
}
Query
{
parameterValuesMap
{
parameterValues.'T1' = ['2014071600','2014072000','segment_id_file']
parameterValues.'T2' = ['Elyon']
}
}
QuartzJob.groovy-->
import org.codehaus.groovy.grails.commons.GrailsApplication;
class MultipleJob
{
GrailsApplication grailsApplication;
static triggers = {
cron name: 'MultipleJobs', cronExpression: "* * * * * ?"
}
def execute()
{
HashMap<String, String> parameter = new HashMap();
grailsApplication.config.ais.Query.Map.time.each
{ k, v ->
if(currentTime=="${k}")
{
String templateId=v[0]
parameterKey = grailsApplication.config.Query.Map.templates.getAt("${v[0]}")
parameterValue = grailsApplication.config.Query.parameterValuesMap.parameterValues.getAt("${v[0]}")
for(int j=0;j<parameterKey.size();j++)
{
parameter.put(parameterKey[j],parameterValue[j])
}
log.info(mediaQueryClient.executeQuery("0", templateId,"arbit", parameter))
}
}
}
}
I want to execute the same execute() method at different times for T1 and T2 at Tue Dec 30 14:48:00 EST 2014 and Wed Dec 30 14:44:00 EST 2014 respectively(I have a total of 25 such templates and all have a different time of execution which cannot be expressed by a single cron expression)can someone provide me with some sample code as to how can i keep executing them all at different time , i don'nt know what cron expression should i keep as the jobs may not be periodically apart hence i cannot have a general cron expression like every 15 minutes ? also can we create multiple cron expressions in a single quartz job ? please provide some sample code
jobManagerService.getQuartzScheduler().scheduleJob(jobTrigger)This way you can define your job without any triggers, and add them as you need (e.g. inBootStrap.groovyor in a service). - Joshua Moore.scheduleJob()Quartz will take care of triggering your jobs on the schedules you defined. - Joshua Moore