简体   繁体   中英

Using Spring Reactor to retrieve data from relational database

当我们从关系数据库获取数据或调用外部 API 端点时,使用 Spring Reactor 的反应式编程是否有意义?

Yes, it can make sense in some cases.

For remote API invocation its possible that it will support a “reactive” way of work. In this case you can use WebClient as a reactive alternative to the battle tested RestTemplate.

You can read about the comparison here

Now with Relational data access things are more complicated. JDBC is not reactive by nature, however there are relational databases that support a reactive way of communication.

There is a reactive alternative of JDBC: called r2dbc and some databases have indeed reactive drivers. There is also an integration with Spring Data, see spring-data-r2dbc project

IMHO this is not ready for production usage though and can be considered as a work in progress that will be done anyway sooner or later.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM