Announcement Announcement Module
Collapse
No announcement yet.
Running footballJob using CommandLineJobRunner with auto-incremented JobParameter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Running footballJob using CommandLineJobRunner with auto-incremented JobParameter

    Hi,

    Sorry for reposting the same question. I would like to run the footballJob through the CommandLineJobRunner without everytime manually incrementing the JobParameter value. I was wondering if I could do the following changes to the footballJob.xml for a dynamic job id incrementer -
    Code:
    <job id="footballJob" incrementer="incrementer">
    
    ...
    
    <beans:bean id="incrementer" class="org.springframework.batch.sample.common.InfiniteLoopIncrementer"/>
    I guess the InfiniteLoopIncrementer creates a JobParameters object containing a "run.id" parameter. If it is possible to use the CommandLineJobRunner to run the footballJob using the JobParameter object from InfiniteLoopIncrementer then what would be CommandLineJobRunner arguments look like?

    Right now I have -
    Code:
    org/springframework/batch/sample/FootballJobFunctionalTests-context.xml footballJob job.run(long)=11
    Is there any other changes I have to do for running the footballJob through CommandLineJobRunner the way I mentioned above?

    Thanks

  • #2
    If you look at the CommandLineJobRunner you'll see that it uses a JobLauncher. In order to use the incrementer, you'll need to launch your job via a JobOperator. So, you should create your own "JobRunner" (you can base it on CommandLineJobRunner) that launches the job with:
    Code:
    jobOperator.startNextInstance(jobName);

    Comment

    Working...
    X