A step-by-step tutorial to learn Spring WebFlux from basics to advanced usage, focusing on real-world reactive programming techniques.
一个循序渐进的教程,从基础到进阶系统地学习 Spring WebFlux,并掌握真实场景下的响应式编程技巧。
Future chapters may explore real-time streaming scenarios such as integrating CEX market data or WebSocket-based data services.
后续章节可能会探索诸如集成 CEX 行情数据或基于 WebSocket 的实时数据服务等流式场景。
- Reactive programming with Mono & Flux (基于 Mono 和 Flux 的响应式编程)
- Build reactive REST APIs (构建响应式 REST API 接口)
- Use WebClient for async HTTP/WebSocket (使用 WebClient 进行异步 HTTP/WebSocket 通信)
- Stream real-time data via SSE / WebSocket (通过 SSE / WebSocket 推送实时数据流)
- Handle retry, reconnection, and backpressure (处理重试、断线重连和背压)
- Design scalable reactive architectures (设计可扩展的响应式架构)
Traditional Spring MVC uses blocking I/O and one thread per request. (传统 Spring MVC 使用阻塞式 I/O,并为每个请求分配独立线程。)
Spring WebFlux is non-blocking, event-loop-based, and highly scalable. (Spring WebFlux 是非阻塞、基于事件循环的,并且具有极高的可扩展性。)
Perfect for real-time, high-concurrency, and streaming data scenarios. (非常适合实时、高并发和流式数据场景。)
- Java 21
- Spring Boot 3+
- Spring WebFlux (Reactor)
- Mono & Flux (Reactive Streams)
- WebClient
- WebSocket / SSE
java-webflux-tutorial
├── chapter01-hello-webflux # Basic WebFlux example
├── chapter02-mono-flux # Coming soon
└── ...
Each chapter is an independent runnable module with focused content. (每个章节都是独立可运行的模块,聚焦于一个知识点。)
| Chapter | Description | 状态 |
|---|---|---|
| 01 - Hello WebFlux | Basic reactive endpoint using @RestController使用 @RestController 构建基础响应式接口 |
✅ Completed |
| 02 - Mono & Flux (Coming soon) | Reactive types and core concepts 响应式类型与核心概念 |
⏳ In Progress |
chapter01-hello-webflux
├── src
│ └── main
│ ├── java
│ │ └── com.kangchain.webflux.chapter01
│ │ ├── HelloWebFluxApplication.java
│ │ └── controller
│ │ └── HelloController.java
│ └── resources
│ └── application.yml
└── pom.xml
Clean and simple structure for quick start.
结构清晰简单,便于快速上手。
This project is evolving chapter by chapter. Suggestions and PRs are welcome!
本教程将持续按章节推进,欢迎提交建议或 Pull Request!
MIT License © KangChain
If this project is helpful, please give it a star ⭐ to support!
如果你觉得这个项目对你有帮助,请点亮一个 star ⭐ 以示支持!
Let’s learn WebFlux and build something amazing together! 🚀
让我们一起学习 WebFlux,并构建出有价值的项目!🚀
