I am trying the reactive stack with MySql at the backend. I was expecting that query results will be a stream , t.e. a heavy query will not wait and return the result when the all the records are found, but will stream them one by one. It does not look that way. The process waits untill the query is done and then returns all the results.
This is the Spring Data repository that I created:
public interface ScopusSpringDataRepo extends ReactiveCrudRepository<Scopus, Long> {
@Query("select" + " SC1.*" + "from Scopus as SC1 join Scopus as SC2"
+ " on SC1.norma like concat(SC2.norma, '%') where ( SC2.norma is not null"
+ " and SC2.word like concat('%', :word, '%'))")
public Flux<Scopus> byNorma(String word);
}
This query is heavy on purpose.
Can someone please explain what behavior is expected from R2DBC in this case?
Thank you.
Update after the comments:
The repository method byNorma is called by a business service that is called by a REST Controller.
Service:
public class ScopusService {
protected ScopusSpringDataRepo scRepo;
public Flux<Scopus> getByNorma(String norma) {
return scRepo.byNorma(norma);
}
}
REST Controller:
public class ScopusController {
protected ScopusService scopusService;
@GetMapping(path = "/stream/scopus/{word}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public ResponseEntity<Flux<Scopus>> getByNorma(@PathVariable String word) {
log.info("Getby norma recieved. word :{}", word);
return ResponseEntity.ok(this.scopusService.getByNorma(word));
}
}
Which is called from a Chromium browser.
Update:
I am trying to understand whether the R2DBC driver sends the result one by one or just gets all the results first and then sends them into the stream at once.