Module 14: Advanced Spring Boot Techniques
Module Objectives
By the end of this module, you will be able to:
- Understand reactive programming with Spring WebFlux
- Implement a cache system with Redis
- Configure asynchronous messaging with RabbitMQ
- Create scheduled tasks with @Scheduled
- Develop real-time applications with WebSockets
Prerequisites
Before starting this module, make sure you master:
- Modules 1-12: Complete Spring Boot Basics
- Module 13: Microservices Architecture
- Docker (for Redis, RabbitMQ)
- Concepts of asynchronous programming
Module Plan
Theoretical Chapters
| # | Chapter | Duration | Description |
|---|---|---|---|
| 1 | Reactive Programming | 1h30 | WebFlux, Mono, Flux, R2DBC |
| 2 | Cache with Redis | 1h | @Cacheable, @CacheEvict, Redis |
| 3 | Asynchronous Messaging | 1h15 | RabbitMQ, Spring AMQP |
| 4 | Scheduled Tasks | 45min | @Scheduled, @Async, Cron |
| 5 | WebSockets | 1h | STOMP, SockJS, real-time |
Practical Work
| # | Lab | Duration | Description |
|---|---|---|---|
| 1 | Redis Cache | 1h | API caching |
| 2 | RabbitMQ Messaging | 1h30 | Notification system |
| 3 | WebSocket Chat | 1h30 | Real-time chat application |
| 4 | Scheduled Tasks | 45min | Batch and automatic reports |
Estimated total duration: 10 hours
Key Concepts
Reactive vs Imperative Programming
Imperative (Spring MVC):
- Thread per request
- Blocking
- Simple to understand
- Limited scalability
Reactive (WebFlux):
- Event loop
- Non-blocking
- High scalability
- Learning curve
When to Use What
| Use Case | Technology |
|---|---|
| Classic CRUD API | Spring MVC |
| High concurrency | WebFlux |
| Frequently read data | Redis Cache |
| Service decoupling | RabbitMQ |
| Real-time notifications | WebSocket |
| Periodic reports | @Scheduled |
Technical Stack
| Technology | Version | Usage |
|---|---|---|
| Spring WebFlux | 3.2.x | Reactive programming |
| Project Reactor | 3.6.x | Mono/Flux |
| Redis | 7.x | Distributed cache |
| RabbitMQ | 3.12.x | Message broker |
| STOMP | 1.2 | WebSocket messaging |
Labs Architecture
Advanced Application
├── REST API (Spring MVC or WebFlux)
├── Cache Layer (Redis)
├── Messaging (RabbitMQ)
├── WebSocket (STOMP)
└── Scheduled Tasks
Ready to Start
Make sure you have Docker installed for this module:
# Check Docker
docker --version
# Start Redis
docker run -d --name redis -p 6379:6379 redis:7-alpine
# Start RabbitMQ
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
Start Chapter 1: Reactive Programming