Q:

How to pass List to Spring Batch ItemReader via REST call

I'm working on a REST method that will perform a job using Spring Batch.
I have a simple job defined,
<job id="myIndexJob" xmlns="http://www.springframework.org/schema/batch">
    <step id="step1">
        <tasklet>
            <chunk reader="myIndexItemReader" processor="myIndexItemProcessor" writer="myIndexItemWriter" commit-interval="1" />
        </tasklet>
    </step>
</job>

This job mimics a question I posted earlier,
Spring Batch ItemReader list processed only once
But this time, instead of executing the job on a schedule, I want to manually execute it via a REST call.
The problem I'm having is passing a List to the myIndexItemReader. My REST call will generate a List based on some query string. The previous question I posted got it's List handed to it via the spring bean in the XML each time the step ran.
I'd like to do something like this,
@RequestMapping(value="/rest/{regex}", method=RequestMethod.GET)
public void run(@PathVariable String regex) {

    List<String> myList = new ArrayList<>();
    myList.add("something");

    long nanoBits = System.nanoTime() % 1000000L;
    if (nanoBits < 0) {
        nanoBits *= -1;
    }
    String dateParam = new Date().toString() + System.currentTimeMillis() 
            + "." + nanoBits;
    JobParameters param = new JobParametersBuilder()
            .addString("date", dateParam)
            .toJobParameters();
    JobExecution execution = jobLauncher.run(job, param);

}

but I just don't know how to pass myList to the myIndexItemReader.
As of now I can do this by creating a RepeatTemplate and calling iterate on a callback, but the job chunk seems more clean.
Anyone have any ideas or suggestions? Thanks /w

A:

I took an alternate approach and stored information in a database table based on the REST criteria. Then the ItemReader read the table and cleared it after each run.

