Skip to main content

Posts

Showing posts from June, 2025

Project Reactor Important Methods Cheat Sheet

  🔹 1️⃣ subscribeOn – "Decides WHERE the Pipeline Starts" 📝 Definition: subscribeOn influences the thread where the data source (upstream) (e.g., data generation, API calls) runs . It affects the source and everything downstream (until a publishOn switches it). Flux<Integer> flux = Flux.range(1, 3)     .doOnNext(i -> System.out.println("[Generating] " + i + " on " + Thread.currentThread().getName()))     .subscribeOn(Schedulers.boundedElastic()) // Change starting thread     .map(i -> {         System.out.println("[Processing] " + i + " on " + Thread.currentThread().getName());         return i * 10;     }); flux.blockLast(); Output  [Generating] 1 on boundedElastic-1 [Processing] 1 on boundedElastic-1 [Generating] 2 on boundedElastic-1 [Processing] 2 on boundedElastic-1 [Generating] 3 on boundedElastic-1 [Processing] 3 on boundedElastic-1 📢 Key Insight: subscribeOn a...