I am trying to stream the data line by line, obtained from reactive MongoDb using spring webflux, but its not streaming instead it gives the response at bulk once the processing is complete it gives the response with the complete data. Below is my code
Controller
@GetMapping("/ldm")
public Flux<String> getAllLdm(){
return employeeService.getAllLDM();
}
Service
public Flux<String> getAllLDM() {
Flux<LDMongo> ldmFlux = repo.findByLogLine1("string being searched");
return ldmFlux.map((l) -> LDMMapper.mapToLogLine(l.getLogLine())).switchIfEmpty(Flux.empty());
}
Repo
@Query("{ 'line' : { $regex: ?0, $options: 'i' } }")
Flux<LDMongo> findByLine(String line);
What is it that I am missing in code