Meow
Meow

Reputation: 135

Using Spring Reactor to retrieve data from relational database

Does it make sense to use reactive programming usind Spring Reactor when we get data from a relational database or when we call an external API endpoint?

Upvotes: 0

Views: 589

Answers (1)

Mark Bramnik
Mark Bramnik

Reputation: 42451

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.

Upvotes: 1

Related Questions