Skip to content

Instantly share code, notes, and snippets.

@AlBaker
Created May 27, 2011 17:41
Show Gist options
  • Save AlBaker/995756 to your computer and use it in GitHub Desktop.
Save AlBaker/995756 to your computer and use it in GitHub Desktop.
Groovy Quartz and Spring Batch
package org.test.quartz.jobs;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
class DailyBatch {
static triggers = {
simple name:'simpleTrigger', startDelay:90000, repeatInterval: 600000
}
// avoid concurrent quartz jobs running, since most batch jobs are stateful and
// designed to be run sequentially
def concurrent = false
// Used by standard quartz stop/start/pause capability
def group = "batchJobs"
def simpleJob // declared in resources.xml, simpleJob = bean name
JobLauncher jobLauncher // declared in resources.xml
def execute() {
log.debug "Running job at ${new Date()}"
JobParameters jobParameters = new JobParametersBuilder().addDate("startTime", new Date()).toJobParameters()
def jobExecution = jobLauncher.run(simpleJob, jobParameters)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment