File tree Expand file tree Collapse file tree
spring-batch/src/main/java/org/baeldung/batch Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import org .springframework .batch .core .Job ;
44import org .springframework .batch .core .JobExecution ;
55import org .springframework .batch .core .JobParameters ;
6+ import org .springframework .batch .core .JobParametersBuilder ;
67import org .springframework .batch .core .launch .JobLauncher ;
78import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
89
@@ -21,7 +22,11 @@ public static void main(final String[] args) {
2122 final Job job = (Job ) context .getBean ("firstBatchJob" );
2223 System .out .println ("Starting the batch job" );
2324 try {
24- final JobExecution execution = jobLauncher .run (job , new JobParameters ());
25+ // To enable multiple execution of a job with the same parameters
26+ JobParameters jobParameters = new JobParametersBuilder ()
27+ .addString ("jobID" , String .valueOf (System .currentTimeMillis ()))
28+ .toJobParameters ();
29+ final JobExecution execution = jobLauncher .run (job , jobParameters );
2530 System .out .println ("Job Status : " + execution .getStatus ());
2631 System .out .println ("Job succeeded" );
2732 } catch (final Exception e ) {
You can’t perform that action at this time.
0 commit comments