Reactive programming(using Spring webFlux) Flashcards
Webflux vs MVC
A reactive, non-blocking stack for dealing with Restful services and client in a non blocking way
MVC uses the Servle tehcnology in a blocking way?
But they both use similar annotations
Webflux uses reactive types (Mono and FLux???)
* it uses different error handling
Spring Reactive web(uses Netty) vs Spring Web(uses Tomcat) dependencies form spring.io
Reactive programming
an asyncronious programming paradigm focused on processing streams of data
*reactive programs work in response to external demands and mostly deal with accurete interupt handling. Real time programs are ususally reactive.
Use case:
External Service Calls
Highly Concurent Message Consumers
SpreadSheets
AbstractionOver Async Processing?
Abstract whether the program si asyn or not?
Features
Data streams
Asyncronious
Non-Blocking
Backpressure
Failure as messages!!!!
Blocking vs NonBlocking
NonBlocking code will process advailable data, will ask to be notified when more is available then continue
Reactive Stream API –> java 9
R2BDC
Reactive Relational Database Connectivity, a specification to integrate SQL databases using reactive drivers
https://spring.io/projects/spring-data-r2dbc
Spring Data R2DBC dependecy STARTER offers support for an array of different databases: H2, MariaDB, Microsoft SQL Server, MySQL, jasync-sql MySQL, Postgres and Oracle
Reactive entities
extend ReactiveCrusdRepository that defines methods to save and retroive data from the database usinf the below 2 reactive entity types:
Mono –> 0 or 1
Flux –> 0 or many
!!!!you need to call subscribe method on Mono or FLux otherwise that operations done on them will not excute!! THe need to be backfired with the subscribe method? ???
Reactive client for consuming rest services
is done with the reactive client: WebClient (oppesite being RestTemplate)