Skip to content

Spring webflux example demonstrating usage of R2DBC + WebClient + Mono/Flux API

License

Notifications You must be signed in to change notification settings

ChristopheMaldivi/spring-webflux-r2dbc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is in the box?

Spring webflux implementation of a simple use case:

  • use the Country REST API (http://restcountries.eu/#api-endpoints-name) to retrieve info on a given country. For this we use the webflux WebClient client.
  • persist data asynchronously in Postgres thanks to the R2DBC asynchronous SQL database driver

Here we rely on the Reactor API, based on Mono and Flux. One could change it to rely on CompletableFuture api.

Now we should use Webflux for asynchronous implementations with Spring, and avoid the @Async stuff. A great video which explains that in details: Servlet vs Reactive Stacks in Five Use Cases

Build, run, test

  • run database: ./rundb.sh
  • run server: ./mvnw clean spring-boot:run
  • retrieve info for China: curl localhost:8080/countries/china
  • retrieve data from database: curl localhost:8080/countries/all

Reference Documentation

For further reference, please consider the following sections:

License

MIT License

About

Spring webflux example demonstrating usage of R2DBC + WebClient + Mono/Flux API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published