<p><span>This book will show you how to build Java-based microservices architecture using the popular Spring Boot framework by evolving a small monolith application to an event-driven architecture composed of several services. This third edition has been updated to cover Spring Boot 3, including its
Learn Microservices with Spring Boot 3: A Practical Approach Using Event-Driven Architecture
β Scribed by MoisΓ©s Macero GarcΓa, Tarun Telang
- Publisher
- Apress
- Year
- 2023
- Tongue
- English
- Leaves
- 475
- Category
- Library
No coin nor oath required. For personal study only.
β¦ Synopsis
This book will show you how to build Java-based microservices architecture using the popular Spring Boot framework by evolving a small monolith application to an event-driven architecture composed of several services. This third edition has been updated to cover Spring Boot 3, including its compatibility with Java 17 and Jakarta EE 10, and employs an incremental approach to teach the structure of microservices, test-driven development, and common patterns in distributed systems such as service discovery, load balancing, routing, centralized logs, per-environment configuration, and containerization.
Authors MoisΓ©s Macero and Tarun Telang get the ball rolling by introducing you to the fundamentals of microservices and Spring Boot before walking you through the development of a basic Spring Boot application. Youβll then see how to build a front end using React, and learn how to use the data layer to read and write data from and to other systems via Spring Boot and its access to Spring Data and its available APIs. Putting together what you've learned thus far, youβll begin to transform an application from a monolith to a microservice.
This pragmatic approach will enable you to better grasp the benefits of using this type of software architecture, instead of keeping you distracted with theoretical concepts. The emphasis is on what matters most, starting with the minimum viable product, while maintaining the ability to adapt and improve your application as needed. After completing this book, you will have the foundational knowledge necessary to build your own microservice-based applications using Spring Boot.
What You Will Learn:
Gain a thorough understanding of microservices architecture and how it differs from monolithic architectures.
Discover the step-by-step process of breaking down a monolithic application into smaller, focused services
Build microservices with Spring Boot 3, Spring Data, Spring Cloud, React.js, Docker, Cucumber, and more
Develop Java-based microservices using the latest version of Spring Boot, compatible with Java 17 and Jakarta EE 10.
Discover architecture patterns for distributed systems such as asynchronous processing, eventual consistency, resilience, scalability, and more
Gain insight into event-driven communication patterns and understand how to design and build event-driven microservices
Trace every request from beginning to end with Sleuth and centralized logging
Deploy your microservices anywhere as Docker containers
Who This Book Is For:
Those with at least some prior experience with Java programming. Some prior exposure to Spring Boot recommended but not required.
β¦ 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
π SIMILAR VOLUMES
About this book Take your distributed applications to the next level and see what the reference architectures associated with microservices can do for you. This book begins by showing you the distributed computing architecture landscape and provides an in-depth view of microservices architecture.
MVC and CRUD make software easier to write, but harder to change. Microservice-based architectures can help even the smallest of projects remain agile in the long term, but most tutorials meander in theory or completely miss the point of what it means to be microservice-based. Roll up your sleeves w