Pagination in SpringBatch ItemReader

Viewed 1496

I want to read data from an api endpoint using spring-batch .Is it possible for me to read the data in a paginated way. Example :-

  • First Request : Read 10 records process and write.
  • Second Request : Read next 10 records process and write.
1 Answers

Since your API already provides pagination, you can create a reader that extends AbstractPagingItemReader and implement the doReadPage method where you call the API to request a page of items (with a configurable size). If the endpoint is a REST endpoint, the reader can use a RestTemplate to make the call.

Related