- I have a paginated REST API which I would like to poll
- Since the source data is growing, I would like to set this up as a scheduled sync job
and rerun it from the point where the previous execution left off (even if it was
COMPLETED) basically advancing on the new data periodically AbstractPaginatedDataItemReaderseems to be suitable, it is able to:- Track the read item count (actually it is
AbstractItemCountingItemStreamItemReader) - Maintain and persist its state in the
ExecutionContext(read.count)
- Track the read item count (actually it is
- What I'm missing is creating the new
JobParametersbased on the previousExecutionContext - It seems
DefaultJobParametersExtractordoes the trick I need - And it is used from the
JobStepclass in a way I need - Unfortunately this is only available to
JobStepand I have aTaskletStep - So I ended up reimplementing the parts I need from
JobStepandDefaultJobParametersExtractor
Is there a better way to do this?
The code in Example.java is what I would like to get rid off by providing the RunIdIncrementer and a JobParametersExtractor.
You are using the
RunIdIncrementerwhich is not the best option IMO. You need a custom incrementer that increments the index based on the latest value from the previous execution. Here is a quick example to illustrate what I mean:With that, you can use a job operator to start the next instance like:
And get rid of the
createJobParametersmethods.Hope this helps.
NB: The
JobParametersIncrementeris only called when you use theJobOperatororCommandLineJobRunnerto run the next instance of a job. So in you example, theRunIdIncrementerhas no effect.