i want to setup a new Batch Job.
This Job should receive a few Parameters from the Rest Interface (i am Using @EnableBatchProcessing for the automated JobScanning).
I only want the job to be performed once per rest call -> thats why i think a tasklet would be the weapon of choice. But i did not get @StepScope to work with a tasklet only Job (it seems as if there is no StepScope available without chunk but please correct me if i am wrong)...
My other idea was to create an ItemReader that reads the JobParameters and create a single Domain Object (from the Parameters) and then processes the Data and writes to a Dummy ItemWriter.
I tried to setup the ItemReader like this:
@Bean
@StepScope
public ItemReader<BatchPrinterJob> setupParameterItemReader(
@Value("#{jobParameters}") Map<String, Object> jobParameters) {
ItemReader<BatchPrinterJob> reader = new ItemReader<BatchPrinterJob>() {
@Override
public BatchPrinterJob read()
throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
BatchPrinterJob job = new BatchPrinterJob();
LOG.info(jobParameters.toString());
return job;
}
};
return reader;
}
i tried to start the job with a POST Request like this: myhost:8080/jobs/thisjobsname?name=testname
But the only thing that gets logged is the run.id.