Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pagination in SpringBatch ItemReader

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.
like image 244
Ankur Saxena Avatar asked Oct 15 '25 14:10

Ankur Saxena


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.

like image 116
Mahmoud Ben Hassine Avatar answered Oct 17 '25 02:10

Mahmoud Ben Hassine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!