Microservices with Spring Boot 3 and Spring Cloud build resilient and scalable microservices using Spring Cloud, Istio, and Kubernetes
With a practical approach, you'll begin with simple microservices and progress to complex distributed applications. Learn essential functionality and deploy microservices using Kubernetes and Istio. This book covers Java 17, Spring Boot 3, and Spring Cloud 2022. Java EE packages are replaced wi...
Otros Autores: | |
---|---|
Formato: | Libro electrónico |
Idioma: | Inglés |
Publicado: |
Birmingham, England :
Packt Publishing Ltd
[2023]
|
Edición: | Third edition |
Materias: | |
Ver en Biblioteca Universitat Ramon Llull: | https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009764836706719 |
Tabla de Contenidos:
- Cover
- Copyright
- Table of Contents
- Preface
- Chapter 1: Introduction to Microservices
- Technical requirements
- My way into microservices
- Benefits of autonomous software components
- Challenges with autonomous software components
- Enter microservices
- A sample microservice landscape
- Defining a microservice
- Challenges with microservices
- Design patterns for microservices
- Service discovery
- Problem
- Solution
- Solution requirements
- Edge server
- Problem
- Solution
- Solution requirements
- Reactive microservices
- Problem
- Solution
- Solution requirements
- Central configuration
- Problem
- Solution
- Solution requirements
- Centralized log analysis
- Problem
- Solution
- Solution requirements
- Distributed tracing
- Problem
- Solution
- Solution requirements
- Circuit breaker
- Problem
- Solution
- Solution requirements
- Control loop
- Problem
- Solution
- Solution requirements
- Centralized monitoring and alarms
- Problem
- Solution
- Solution requirements
- Software enablers
- Other important considerations
- Summary
- Chapter 2: Introduction to Spring Boot
- Technical requirements
- Spring Boot
- Convention over configuration and fat JAR files
- Code examples for setting up a Spring Boot application
- The magic @SpringBootApplication annotation
- Component scanning
- Java-based configuration
- What's new in Spring Boot 3.0
- Migrating a Spring Boot 2 application
- Spring WebFlux
- Code examples of setting up a REST service
- Starter dependencies
- Property files
- Sample RestController
- springdoc-openapi
- Spring Data
- Entity
- Repositories
- Spring Cloud Stream
- Code examples for sending and receiving messages
- Docker
- Summary
- Questions
- Chapter 3: Creating a Set of Cooperating Microservices
- Technical requirements.
- Introducing the microservice landscape
- Information handled by the microservices
- The product service
- The review service
- The recommendation service
- The product composite service
- Infrastructure-related information
- Temporarily replacing service discovery
- Generating skeleton microservices
- Using Spring Initializr to generate skeleton code
- Setting up multi-project builds in Gradle
- Adding RESTful APIs
- Adding an API and a util project
- The api project
- The util project
- Implementing our API
- Adding a composite microservice
- API classes
- Properties
- The integration component
- Composite API implementation
- Adding error handling
- The global REST controller exception handler
- Error handling in API implementations
- Error handling in the API client
- Testing APIs manually
- Adding automated microservice tests in isolation
- Adding semi-automated tests of a microservice landscape
- Trying out the test script
- Summary
- Questions
- Chapter 4: Deploying Our Microservices Using Docker
- Technical requirements
- Introduction to Docker
- Running our first Docker commands
- Running Java in Docker
- Limiting available CPUs
- Limiting available memory
- Using Docker with one microservice
- Changes in source code
- Building a Docker image
- Starting up the service
- Running the container in detached mode
- Managing a landscape of microservices using Docker Compose
- Changes in the source code
- Starting up the microservice landscape
- Automating tests of cooperating microservices
- Troubleshooting a test run
- Summary
- Questions
- Chapter 5: Adding an API Description Using OpenAPI
- Technical requirements
- Introduction to using springdoc-openapi
- Adding springdoc-openapi to the source code
- Adding dependencies to the Gradle build files.
- Adding OpenAPI configuration and general API documentation to the ProductCompositeService
- Adding API-specific documentation to the ProductCompositeService interface
- Building and starting the microservice landscape
- Trying out the OpenAPI documentation
- Summary
- Questions
- Chapter 6: Adding Persistence
- Technical requirements
- Chapter objectives
- Adding a persistence layer to the core microservices
- Adding dependencies
- Storing data with entity classes
- Defining repositories in Spring Data
- Writing automated tests that focus on persistence
- Using Testcontainers
- Writing persistence tests
- Using the persistence layer in the service layer
- Logging the database connection URL
- Adding new APIs
- Calling the persistence layer from the service layer
- Declaring a Java bean mapper
- Updating the service tests
- Extending the composite service API
- Adding new operations to the composite service API
- Adding methods to the integration layer
- Implementing the new composite API operations
- Updating the composite service tests
- Adding databases to the Docker Compose landscape
- The Docker Compose configuration
- Database connection configuration
- The MongoDB and MySQL CLI tools
- Manual tests of the new APIs and the persistence layer
- Updating the automated tests of the microservice landscape
- Summary
- Questions
- Chapter 7: Developing Reactive Microservices
- Technical requirements
- Choosing between non-blocking synchronous APIs and event-driven asynchronous services
- Developing non-blocking synchronous REST APIs
- An introduction to Project Reactor
- Non-blocking persistence using Spring Data for MongoDB
- Changes in the test code
- Non-blocking REST APIs in the core services
- Changes in the APIs
- Changes in the service implementations
- Changes in the test code.
- Dealing with blocking code
- Non-blocking REST APIs in the composite services
- Changes in the API
- Changes in the service implementation
- Changes in the integration layer
- Changes in the test code
- Developing event-driven asynchronous services
- Handling challenges with messaging
- Consumer groups
- Retries and dead-letter queues
- Guaranteed order and partitions
- Defining topics and events
- Changes in the Gradle build files
- Consuming events in the core services
- Declaring message processors
- Changes in the service implementations
- Adding configuration for consuming events
- Changes in the test code
- Publishing events in the composite service
- Publishing events in the integration layer
- Adding configuration for publishing events
- Changes in the test code
- Running manual tests of the reactive microservice landscape
- Saving events
- Adding a health API
- Using RabbitMQ without using partitions
- Using RabbitMQ with partitions
- Using Kafka with two partitions per topic
- Running automated tests of the reactive microservice landscape
- Summary
- Questions
- Chapter 8: Introduction to Spring Cloud
- Technical requirements
- The evolution of Spring Cloud
- Using Netflix Eureka for service discovery
- Using Spring Cloud Gateway as an edge server
- Using Spring Cloud Config for centralized configuration
- Using Resilience4j for improved resilience
- Sample usage of the circuit breaker in Resilience4j
- Using Micrometer Tracing and Zipkin for distributed tracing
- Summary
- Questions
- Chapter 9: Adding Service Discovery Using Netflix Eureka
- Technical requirements
- Introducing service discovery
- The problem with DNS-based service discovery
- Challenges with service discovery
- Service discovery with Netflix Eureka in Spring Cloud
- Setting up a Netflix Eureka server.
- Connecting microservices to a Netflix Eureka server
- Setting up the configuration for development use
- Eureka configuration parameters
- Configuring the Eureka server
- Configuring clients to the Eureka server
- Trying out the discovery service
- Scaling up
- Scaling down
- Disruptive tests with the Eureka server
- Stopping the Eureka server
- Starting up an extra instance of the product service
- Starting up the Eureka server again
- Summary
- Questions
- Chapter 10: Using Spring Cloud Gateway to Hide Microservices behind an Edge Server
- Technical requirements
- Adding an edge server to our system landscape
- Setting up Spring Cloud Gateway
- Adding a composite health check
- Configuring Spring Cloud Gateway
- Routing rules
- Trying out the edge server
- Examining what is exposed outside the Docker engine
- Trying out the routing rules
- Calling the product composite API through the edge server
- Calling the Swagger UI through the edge server
- Calling Eureka through the edge server
- Routing based on the host header
- Summary
- Questions
- Chapter 11: Securing Access to APIs
- Technical requirements
- Introduction to OAuth 2.0 and OpenID Connect
- Introducing OAuth 2.0
- Introducing OpenID Connect
- Securing the system landscape
- Protecting external communication with HTTPS
- Replacing a self-signed certificate at runtime
- Securing access to the discovery server
- Changes in the Eureka server
- Changes in Eureka clients
- Adding a local authorization server
- Protecting APIs using OAuth 2.0 and OpenID Connect
- Changes in both the edge server and the product-composite service
- Changes in the product-composite service only
- Changes to allow Swagger UI to acquire access tokens
- Changes in the test script
- Testing with the local authorization server
- Building and running the automated tests.
- Testing the protected discovery server.