Lucas Batista’s Post

Reactive Programming in Java Just spent time getting hands-on with Project Reactor (Mono/Flux), and for projects stuck in older versions of Java (pre-21), the strategy is worth the hype. For years, traditional Java (Spring MVC) followed a simple rule: One request = One thread. While straightforward, it leaves threads idle while waiting for databases or external APIs, specifically when dealing with file upload or large data. Reactive programming (Spring WebFlux) is a whole different idea: * Non-blocking I/O: Instead of waiting idly, threads handle other requests while data is in transit. * Elasticity: Handles high concurrency with fewer hardware resources. * Resilience: Built-in backpressure ensures the system doesn’t crash when traffic spikes, as well as great strategies for handling errors Switching from RestTemplate (blocking) to WebClient (non-blocking) with Mono showed me how to compose asynchronous logic declaratively. It feels strange and confusing at first, but the ability to chain operations without blocking threads is incredibly powerful. Although useful before Java 21's Virtual Threads, Spring WebFlux is now almost obsolete, being useful only in very specific cases. Thanks to all users who pointed it out in the comments. If you also want to learn more: https://projectreactor.io #Java #ReactiveProgramming #SpringBoot #WebFlux #SoftwareEngineering #Coding #AlwaysLearning

Excelente ponto 👏 Também tive essa mesma sensação quando comecei com WebFlux… no começo parece que “quebra” a forma de pensar tradicional do Java, mas depois que você entende o fluxo reativo, faz muito sentido. Já usei em cenários com muitas integrações externas (APIs + filas), e o ganho de throughput foi bem perceptível — principalmente por não ficar preso no modelo 1 thread por request. Mas concordo contigo sobre o momento atual: com a chegada das Virtual Threads no Java 21, muita coisa ficou mais simples de resolver sem toda a complexidade do modelo reativo. Hoje vejo assim: 👉 WebFlux ainda é excelente para cenários bem específicos (alta concorrência + I/O pesado) 👉 Virtual Threads resolvem 80% dos casos com muito menos complexidade No fim, é aquela velha máxima: não existe bala de prata — existe o trade-off certo pro problema certo Curti demais o insight 🚀

Nice insights Lucas Batista, reactive really changes how you think about concurrency, it’s not just about performance, but about using resources more efficiently under high I/O pressure.

Yes, the idea is powerful. Unfortunately, reactive streams are not the most convenient API for this. Functional-style Promise gives a similar API and even more powerful composition without the introduction of convoluted API and artificial mental model. Take a look here: https://dev.to/siy/we-should-write-java-code-differently-lets-get-practical-1ib2

For 90% of the projects, traditional spring MVC + virtual threads is good enough. Much much more readable code.

Yes, but we already have virtual threads, which are a better option nowadays from my point of view.

Since java 21 virtual threads, "reactive java" is obsolete and a debugging hell. But it made a lot sense for thread optimization back then. Still I strongly oppose promoting RX java without mentioning its resolved version of java 21, it may lead people to do awful architectural decisions.

Like
Reply

This is good but only issue is debugging any customer issues is a night-mare to reproduce!

Nice post! 👍 Thanks for sharing!

Virtual threads don't have "backpressure" concept which is a foundation and in grained in WebFlux(it supports natively as well as you can customize) WebFlux is very much needed for steaming data - SSE, WebSockets, Flux responses. Is needed for extreme concurrency. When u need gateways, brokers or fan ourt services. Spring Cloud still uses WebFlux. Spring AI has options for streaming LLM via WebFlux. So where is its demise?

Like
Reply

Great point! Reactive programming with Project Reactor is definitely a game-changer for high-concurrency systems, especially with how WebClient handles non-blocking I/O so much more efficiently than the old RestTemplate.However, with Virtual Threads, the "One thread per request" model is making a massive comeback. Virtual threads are so lightweight that you can go back to writing simple, imperative code without the "callback hell" or complex operators of Mono/Flux, while still achieving massive scalability.

See more comments

To view or add a comment, sign in

Explore content categories