Created
May 27, 2011 17:41
-
-
Save AlBaker/995756 to your computer and use it in GitHub Desktop.
Groovy Quartz and Spring Batch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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