Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Spring WebFlux vs RxJava

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?

like image 970
user1955934 Avatar asked Jun 05 '19 13:06

user1955934


People also ask

Should I use spring WebFlux?

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.

Why do we use spring WebFlux?

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.

Is Spring WebFlux production ready?

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.

What is the difference between Java and RxJava?

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.


1 Answers

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.

like image 73
AAAAR Avatar answered Sep 19 '22 21:09

AAAAR