webflux-reactive-patterns

Solid

Use when the complete Spring Boot 3 request path is reactive: WebFlux controllers, Reactor pipelines, R2DBC persistence, streaming, backpressure, or cancellation. For defining and registering declarative outbound API interfaces, use http-interface-clients.

Web & Frontend 225 stars 37 forks Updated 6 days ago MIT

Install

View on GitHub

Quality Score: 85/100

Stars 20%
78
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
96
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# WebFlux Reactive Patterns Use WebFlux when the complete request path can benefit from non-blocking I/O. ## Pipeline rules - Return `Mono` or `Flux`; do not call `subscribe()` in request-handling code. - Compose work with `map`, `flatMap`, `concatMap`, and `zip` according to ordering requirements. - Keep blocking JDBC, filesystem, and legacy SDK calls out of event-loop threads. - Isolate unavoidable blocking calls on `boundedElastic` at the narrow adapter boundary. - Apply timeouts at remote-call boundaries and preserve cancellation. ## Context and errors - Put request-scoped metadata in Reactor `Context`, not `ThreadLocal`. - Translate domain failures centrally without swallowing cancellation or infrastructure errors. - Use `onErrorResume` only when a defined fallback exists. - Avoid `onErrorContinue`; it makes partial processing hard to reason about. ## Persistence and streaming - Use R2DBC for reactive database access; JDBC makes the pipeline blocking. - Bound concurrency for fan-out operations. - Define backpressure and buffering limits for streaming endpoints. - Avoid collecting an unbounded `Flux` into memory. ## Testing - Use `StepVerifier` for publisher behavior and `WebTestClient` for HTTP contracts. - Test cancellation, timeout, empty results, errors, ordering, and backpressure. - Enable blocking-call detection in tests when the project supports it. ## Examples - See `examples/good-reactive-service.java` and `examples/bad-reactive-service.java`. ## Gotc...

Details

Author
rrezartprebreza
Repository
rrezartprebreza/spring-boot-skills
Created
4 months ago
Last Updated
6 days ago
Language
Java
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category