- 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 AbstractPaginatedDataItemReader
seems 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
JobParameters
based on the previousExecutionContext
- It seems
DefaultJobParametersExtractor
does the trick I need - And it is used from the
JobStep
class in a way I need - Unfortunately this is only available to
JobStep
and I have aTaskletStep
- So I ended up reimplementing the parts I need from
JobStep
andDefaultJobParametersExtractor
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
RunIdIncrementer
which 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
createJobParameters
methods.Hope this helps.
NB: The
JobParametersIncrementer
is only called when you use theJobOperator
orCommandLineJobRunner
to run the next instance of a job. So in you example, theRunIdIncrementer
has no effect.