Learn Microservices with Spring Boot
A Practical Approach to Distributed Systems (2nd Edition)
This book presents an evolutionary and practical approach to distributed software architectures. Learn how to transition from a monolithic system to a microservices-based architecture while avoiding common pitfalls.
📖 350+ pages • ⭐ 4.5/5 rating • 🔄 2nd Edition (2020) • 💻 Full code examples
Master Microservices Step by Step
This book takes you through a practical journey, building real microservices while learning the patterns and practices that matter.
Practical Evolution
Start with a monolith (the best option to begin) and evolve to microservices when needed.
Spring Boot Mastery
Build microservices with Spring Boot using 3-tier, 3-layer design patterns.
Event-Driven Architecture
Implement resilience and scalability with RabbitMQ and asynchronous communication.
Cloud Patterns
Master service discovery with Consul, load balancing, and Spring Cloud Gateway.
Observability
Trace requests with Sleuth, implement centralized logging, and monitoring.
Containerization
Deploy microservices as Docker containers with Buildpacks and Docker Compose.
Learn by Building a Real System
All the contents in the book are presented around a practical case study that evolves each chapter with the introduction of new concepts.
You start with a small monolith, looking at the best design practices, and you learn how Spring Boot works with real examples.
Then, you introduce a second microservice in the system, and study the differences between synchronous and asynchronous communication. That's how you get to Event-Driven architectures. Once you enter into the world of microservices, you must learn the most important architecture patterns for distributed systems: Gateway, Service Discovery, Load Balancing, Resilience, Scalability, Distributed Tracing, and more.
- Start with a monolith
- Evolve to microservices
- Learn patterns in practice
- Build real solutions
Comprehensive Coverage
Introduction
Setting the scene for microservices and understanding the approach of this book.
- Setting the scene
- Who are you?
- How is this book different from others?
- Contents
- Online Contents
Core Concepts
Spring Boot fundamentals and testing strategies that will be used throughout the book.
- Spring
- Spring Boot
- Lombok and Java
- Testing basics: TDD, BDD, JUnit, Mockito, AssertJ
- Testing in Spring Boot
- Logging
- Summary
A Basic Spring Boot App
Building the foundation application with proper architecture patterns.
- Intro
- Business Requirements
- Setting up the development environment
- The Skeleton Web App
- Spring Boot Auto-Configuration
- Three-tier, Three-layer Architecture
- Modeling my domain
- Business logic
- The Presentation Layer
- Summary
A Minimal Frontend with React
Creating a user interface to interact with my Spring Boot backend.
- Quick intro to React and Node
- Setting up the development environment
- The React app skeleton
- A JavaScript REST Client
- The Challenge Component
- Running my frontend for the first time
- Debugging
- Adding CORS configuration
- Playing with the app
- Deploying the frontend
- Summary
The Data Layer
Implementing persistence with Spring Data JPA and best practices.
- Intro
- The Data Model
- Choosing a database
- Spring Boot Data JPA
- Entities
- Repositories
- Storing users and attempts
- New APIs and UI
- Playing with the new feature
- Summary
Starting with Microservices
Moving from monolith to microservices architecture with practical examples.
- Intro: what happened until now
- The Small Monolith approach
- New requirements and Gamification
- When should I move to microservices?
- Why microservices?
- Architecture Overview
- Designing and implementing the new microservice
- Playing with the system
- Fault Tolerance
- The challenges ahead
- Summary
Event-Driven Architecture
Implementing asynchronous communication with RabbitMQ and Spring AMQP.
- Core Concepts
- Pros and Cons of Event-Driven
- Messaging Patterns
- Message Broker Protocols, Standards and Tools
- AMQP and RabbitMQ
- Setting up RabbitMQ
- Spring AMQP and Spring Boot
- Solution Design
- Analysis: happy flow, resilience, and scalability
- Summary
Common Patterns in Microservice Architectures
Essential patterns for building robust microservice systems.
- Gateway
- Health
- Service Discovery & Load Balancing
- Configuration per Environment
- Centralized Logs
- Distributed Tracing
- Containerization
- Platforms and Cloud-Native Microservices
- Summary
Foreword
Final thoughts and next steps in your microservices journey.
Book's Extra Chapters
For this second edition, I'm creating book extensions that give you extra insights on other topics not included in the book. Subscribe to the newsletter to get the latest posts and guides.
End-to-End Tests with Cucumber
Learn how to create end-to-end tests to verify the functionality from solving challenges to getting score and badges.
Spring Boot 2.7.1 and Spring Cloud 2021.0.3
Step-by-step migration guide from Spring Boot 2.6 to Spring Boot 2.7 for the book's project.
Spring Boot 2.6.2 and Spring Cloud 2021.0
Step-by-step migration guide from Spring Boot 2.5 to Spring Boot 2.6 for the book's project.
Spring Boot 2.5.5 and Java 17
Step-by-step migration guide from Spring Boot 2.4 to Spring Boot 2.5.5 for the book's project.
Spring Boot 2.4.0, Spring Cloud 2020.0, and Java 15
Step-by-step migration guide from Spring Boot 2.3 to Spring Boot 2.4 for the book's microservice architecture project.