I’m tring build a resful api with Spring WebFlux, and I found when I making Flux Object be restful would make request‘s Waiting time longer, but I read another thread said that collectList() is not blocking thread.
@RestController
@RequestMapping("/test")
class TestController {
@Autowired
lateinit var articleService: ArticleService
// Used for wrapping response to RESTFul
val mapper: (Any) -> Mono<Any> = { it: Any -> Mono.just(RestResponse(200, "success", it)) }
@GetMapping("/a")
fun getArticles() = articleService.queryAll()
@GetMapping("/b")
fun getArticles2() = articleService.queryAll()
.collectList()
// .flatMap(mapper) If without collectList(), cant warp response
}
Requesting /test/a
Requesting /test/b
In addition, I’m trying to think to create a empty Mono object and use Callback function to finish wraping the response to restful but seems dont work
sheip9 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.