I’m starting to learn reactive programming in Java. The whole reactive paradigm is new to me.
In my learning process, i have come across few terms/libraries such as Spring WebFlux, projectreactor, and RxJava. I hope someone can explain what the differences are, and which one you used for your project and why you have made this choice.
I read that Spring WebFlux actually uses projectreactor's Flux/Mono internally. This simplified the question to pros and cons of Spring Webflux over RxJava?
Spring WebFlux is a good fit for highly concurrent applications, applications that need to be able to process a large number of requests with as few resources as possible, for applications that need scalability or for applications that need to stream request data in a live manner.
Spring WebFlux allows us to decompose the logic in a declarative way with Mono, Flux, and their rich operator sets. Moreover, we can have functional endpoints besides its @Controller annotated ones, though we can now also use these in Spring MVC.
A Quick Guide To Build Reactive Spring WebFlux Spring MVC has been a popular framework not only because of its simplicity but also its offering of a wide range of production ready features, enabling rapid system development. Many enterprises built mission critical systems based on this framework.
Java 8 Streams enable processing of really large collections efficiently, while leveraging multicore architectures. In contrast, RxJava is single-threaded by default (without Schedulers). So RxJava won't take advantage of multi-core machines unless you code that logic yourself.
In general, RxJava support project which based on JDK8- and Project Reactor supports JDK 8+. But for a beginner, you can learn RxJava at first. Since Project Reactor you can consider it fix the drawbacks in RxJava and more suitable for Backend development. RxJava has too many problems which can cause Out of Memory if you can't use it well. But in final, if you want to use Spring 5.2+ very well, you need to learn from RxJava->Reactor->NIO->Netty->Reactor netty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With