Introducing RxJava into a Spring Boot REST API
summary
Stepwise migration of a Spring Boot REST API into RxJava converts blocking services into Observables, shows how to use map/flatMap/zip to transform and combine streams, and handles failures with onErrorResumeNext and retry (cold vs hot sources matter for retries). Examples include counting users, summing hash power for a Dogecoin mining pool, and falling back from a flaky free FX API to a paid API. Controllers temporarily use toBlocking then move to Spring DeferredResult for nonblocking responses; tests use MockMvc async dispatch.
AI-written summary · about
chapters (14)
- 0:00Introduction to RxJava
- 1:00Why blocking code is bad
- 8:28RxJava basics and Observable
- 11:00Migrating legacy Spring Boot app
- 16:46First RxJava operator: map
- 24:29Blocking vs non-blocking in controllers
- 34:08Flat map and reduce operators
- 40:30Filter, take and count operators
- 48:34Side effects with doOn operators
- 51:06Combining observables: concat, merge, zip
- 1:01:26Error handling: retry and onError
- 1:15:51Fallback strategies with onErrorResume
- 1:27:11Making controllers reactive in Spring
- 1:33:18Summary and takeaways
related talks
45mApplying Reactive Programming with Rx
49mFunctional Reactive Programming with RxJava
39mAdvanced Networking with RxJava + Retrofit
30mReactive Applications with rxjava / Spring Reactor
43mMigrating from Imperative to Reactive
32mRX Java with Kotlin in Baby Steps
37mA Practical Guide To master Rx Streams
52mReactive Programming in Java
