Learn Microservices with Spring Boot 3: A Practical Approach Using Event-Driven Architecture
9781484297568, 9781484297575
This book will show you how to build Java-based microservices architecture using the popular Spring Boot framework by ev
183
73
5MB
English
Pages 475
Year 2023
Report DMCA / Copyright
DOWNLOAD EPUB FILE
Table of contents :
Table of Contents
About the Authors
About the Technical Reviewer
Acknowledgments
About this Book
Chapter 1: Setting the Scene
Who Are You?
How Is This Book Different from Other Books and Guides?
Learning: An Incremental Process
Is This a Guide or a Book?
From Basics to Advanced Topics
Skeleton with Spring Boot, the Professional Way
Test-Driven Development
Microservices
Event-Driven Systems
Nonfunctional Requirements
Online Content
Summary
Chapter 2: Basic Concepts
Spring
Spring Boot
Lombok and Java
Testing Basics
Test-Driven Development
Behavior-Driven Development
JUnit 5
Mockito
AssertJ
Testing in Spring Boot
Logging
Summary and Achievements
Chapter 3: A Basic Spring Boot Application
Setting Up the Development Environment
Java Development Kit 17
Integrated Development Environment (IDE)
HTTPie
Working with JSON
GET Request
POST Request
cURL
The Skeleton Web App
Spring Boot Autoconfiguration
Three-Tier, Three-Layer Architecture
Modeling the Domain
Domain Definition and Domain-Driven Design
Domain Classes
Business Logic
What You Need
Random Challenges
Attempt Verification
Presentation Layer
REST
REST APIs with Spring Boot
Designing the APIs
Your First Controller
How Automatic Serialization Works
Testing Controllers with Spring Boot
Valid Attempt Test
Validating Data in Controllers
Summary and Achievements
Chapter 4: A Minimal Frontend with React
A Quick Intro to React and Node
Setting Up the Development Environment
The React Skeleton
A JavaScript Client
The Challenge Component
The Main Structure of a Component
Rendering
Integration with the App
Running the Frontend the First Time
Debugging
Adding CORS Configuration to the Spring Boot App
Playing with the Application
Deploying the React App
Summary and Achievements
Chapter 5: The Data Layer
The Data Model
Choosing a Database
SQL vs. NoSQL
H2, Hibernate, and JPA
Spring Boot Data JPA
Dependencies and Autoconfiguration
Spring Boot Data JPA Technology Stack
Data Source (Auto)configuration
Entities
Repositories
Storing Users and Attempts
Displaying Last Attempts
Service Layer
Controller Layer
User Interface
Playing with the New Feature
Summary and Achievements
Chapter 6: Starting with Microservices
The Small Monolith Approach
Why a Small Monolith?
The Problems with Microservices from Day Zero
Small Monoliths Are for Small Teams
Embracing Refactoring
Planning the Small Monolith for a Future Split
New Requirements and Gamification
Gamification: Points, Badges, and Leaderboards
Moving to Microservices
Independent Workflows
Horizontal vs. Vertical Scalability
Fine-Grained Nonfunctional Requirements
Other Advantages
Disadvantages
Architecture Overview
Designing and Implementing the New Service
Interfaces
The Spring Boot Skeleton for Gamification
Domain
Service
Data
Controller
Configuration
Changes in Multiplication Microservice
UI
Playing with the System
Fault Tolerance
The Challenges Ahead
Tight Coupling
Synchronous Interfaces vs. Eventual Consistency
Transactions
API Exposure
Summary and Achievements
Chapter 7: Event-Driven Architectures
Core Concepts
The Message Broker
Events and Messages
Thinking in Events
Asynchronous Messaging
Reactive Systems
Pros and Cons of Going Event-Driven
Messaging Patterns
Publish-Subscribe
Work Queues
Filtering
Data Durability
Message Broker Protocols, Standards, and Tools
AMQP and RabbitMQ
Overall Description
Exchange Types and Routing
Message Acknowledgments and Rejection
Setting Up RabbitMQ
Spring AMQP and Spring Boot
Solution Design
Adding the AMQP Starter
Event Publishing from Multiplication
Gamification as a Subscriber
Analysis of Scenarios
Happy Flow
Gamification Becomes Unavailable
The Message Broker Becomes Unavailable
Transactionality
Scaling Up Microservices
Summary and Achievements
Chapter 8: Common Patterns in Microservice Architectures
Gateway
Spring Cloud Gateway
The Gateway Microservice
Changes in Other Projects
Running the Gateway Microservice
Next Steps
Health
Spring Boot Actuator
Including Actuator in Your Microservices
Service Discovery and Load Balancing
Consul
Spring Cloud Consul
Spring Cloud Load Balancer
Service Discovery and Load Balancing in the Gateway
Playing with Service Discovery and Load Balancing
Configuration per Environment
Configuration in Consul
Spring Cloud Consul Config
Implementing Centralized Configuration
Centralized Configuration in Practice
Centralized Logs
Log Aggregation Pattern
A Simple Solution for Log Centralization
Consuming Logs and Printing Them
Distributed Tracing
Spring Cloud Sleuth
Implementing Distributed Tracing
Containerization
Docker
Spring Boot and Buildpacks
Running Your System in Docker
Dockerizing Microservices
Dockerizing the UI
Dockerizing the Configuration Importer
Docker Compose
Scaling Up the System with Docker
Sharing Docker Images
Platforms and Cloud-Native Microservices
Container Platforms
Application Platforms
Cloud Providers
Making a Decision
Cloud-Native Microservices
Conclusions
Index