I have a paginated response from an URL, I want to keep on hitting the next page URL which I get from the previous response and keep on collecting items till I don't have a "nextPage" URL in my response. How to achieve this in a reactive way using spring boot WebClient from WebFlux with out blocking?
Request1:
GET /items
response:
{
items: [...]
nextPage: "/items?page=2"
}
Request2:
GET /items?page=2
response:
{
items: [...]
nextPage: "/items?page=3"
}
Request3:
GET /items?page=3
response:
{
items: [...]
nextPage: null
}
Here I have created mock urls https://karthikdivi.com/apps/paginatedReviews/withNextPageTokens/items https://karthikdivi.com/apps/paginatedReviews/withNextPageTokens/items?page=2 https://karthikdivi.com/apps/paginatedReviews/withNextPageTokens/items?page=3
How can I extract all Items from the above responses in a reactive way without blocking?
Flux<Item>
would potentially allow the pipeline to continue downstream while other requests are executing. CallingcollectList
will wait until the whole expand is complete before completing theMono
- by wait I don’t mean “block”, just the rest of the pipeline won’t continue. – Hilltop