https://stackoverflow.com/questions/46918303/jdbc-with-webflux-how-to-dispatch-to-container-thread
In Spring WebFlux, you will call reactive libraries that return monos and fluxes and your controllers will return monos and fluxes. Because these return immediately, your controllers will effectively give up their threads and allow Reactor to handle responses asynchronously. It is important to note that only by using reactive libraries can your WebFlux services stay reactive. If you use non-reactive libraries, such as JDBC calls, your code will block and wait for those calls to complete before returning.
Reactive programming with MongoDB
Currently, there aren’t many reactive database libraries, so you may be wondering if it’s practical to write reactive services. The good news is that MongoDB has reactive support and there are a couple of third-party reactive database drivers for MySQL and Postgres. For all other use cases, WebFlux provides a mechanism for executing JDBC calls in a reactive manner, albeit using a secondary thread pool that makes blocking JDBC calls.
本文探讨了在Spring WebFlux中如何处理JDBC调用以保持服务的反应式特性。WebFlux允许控制器返回Mono和Flux,但使用非反应式库如JDBC会导致代码阻塞。文章介绍了如何通过使用辅助线程池执行JDBC调用来避免阻塞,以及MongoDB等数据库的反应式支持。
1904

被折叠的 条评论
为什么被折叠?



