- basically just wrap things in
Mono
, likeMono.just("someString")
, flux is like a stream - spring data reactive repositories main concern and still in incuberator, has good support for SQL, and some NoSQL, DynamoDB might be hard at the moment. Is better performing that JDBC (see 3.) it's largely based around R2DBC (see 1.), had issues with h2-console, and schema.sql/data.sql seems to be handled differently
- can apparently handle 1.5 times the number of requests of Servlet stack (see 2.) with a small server, has lower memory, and cpu footprint
- JSON isn't really streamed but
Flux
is useful for that - code can look really similar to what you are used to (link code)
- reactive means basically non-blocking
- using RouterFunctions routing is an option, but maybe not a good one (https://spring.io/guides/gs/reactive-rest-service/)
References
- R2DBC: https://github.com/r2dbc for example is for h2 database: https://github.com/r2dbc/r2dbc-h2
- https://medium.com/@the.raj.saxena/springboot-2-performance-servlet-stack-vs-webflux-reactive-stack-528ad5e9dadc
- R2DBC performance seems fine with a connect pool: https://technology.amis.nl/software-development/performance-and-tuning/performance-of-relational-database-drivers-r2dbc-vs-jdbc/ https://technology.amis.nl/software-development/performance-and-tuning/spring-blocking-vs-non-blocking-r2dbc-vs-jdbc-and-webflux-vs-web-mvc/
Should configure a connection pool with r2dbc: https://github.com/r2dbc/r2dbc-pool/blob/b16b8aad71bbe78c55943e66278df4758d8cb538/src/main/java/io/r2dbc/pool/ConnectionPool.java https://github.com/r2dbc/r2dbc-pool/tree/b16b8aad71bbe78c55943e66278df4758d8cb538
Notes: