liveBook · Manning

What you will learn in Spring Microservices in Action

by John Carnell

Chapter by chapter

Chapter 1: Chapter 1. Welcome to the cloud, Spring

The chapter introduction defines microservices and previews building them with Java and Spring.

1.1 What’s a microservice? · 1.2 What is Spring and why is it relevant to microservices? · 1.3 What you’ll learn in this book · 1.4 Why is this book relevant to you? · 1.5 Building a microservice with Spring Boot · 1.6 Why change the way we build applications? · 1.7 What exactly is the cloud? · 1.8 Why the cloud and microservices? · 1.9 Microservices are more than writing the code · 1.9.1 Core microservice development pattern · 1.9.2 Microservice routing patterns · 1.9.3 Microservice client resiliency patterns · 1.9.4 Microservice security patterns · 1.9.5 Microservice logging and tracing patterns · 1.9.6 Microservice build/deployment patterns · 1.10 Using Spring Cloud in building your microservices · 1.10.1 Spring Boot · 1.10.2 Spring Cloud Config · 1.10.3 Spring Cloud service discovery · 1.10.4 Spring Cloud/Netflix Hystrix and Ribbon · 1.10.5 Spring Cloud/Netflix Zuul · 1.10.6 Spring Cloud Stream · 1.10.7 Spring Cloud Sleuth · 1.10.8 Spring Cloud Security · 1.10.9 What about provisioning? · 1.11 Spring Cloud by example · 1.12 Making sure our examples are relevant · 1.13 Summary

What you learn in chapter 1 →

Chapter 2: Chapter 2. Building microservices with Spring Boot

The introduction explains microservice characteristics, their benefits for cloud applications, and the perspectives needed to design and operate them.

2.1 The architect’s story: designing the microservice architecture · 2.1.1 Decomposing the business problem · 2.1.2 Establishing service granularity · 2.1.3 Talking to one another: service interfaces · 2.2 When not to use microservices · 2.2.1 Complexity of building distributed systems · 2.2.2 Server sprawl · 2.2.3 Type of application · 2.2.4 Data transformations and consistency · 2.3 The developer’s tale: building a microservice with Spring Boot and Java · 2.3.1 Getting started with the skeleton project · 2.3.2 Booting your Spring Boot application: writing the Bootstrap class · 2.3.3 Building the doorway into the microservice: the Spring Boot controller · 2.4 The DevOps story: building for the rigors of runtime · 2.4.1 Service assembly: packaging and deploying your microservices · 2.4.2 Service bootstrapping: managing configuration of your microservices · 2.4.3 Service registration and discovery: how clients communicate with - your microservices · 2.4.4 Communicating a microservice’s health · 2.5 Pulling the perspectives together · 2.6 Summary

What you learn in chapter 2 →

Chapter 3: Chapter 3. Controlling your configuration with Spring Cloud configuration server

This introduction explains why microservices need configuration separated from code and outlines a scalable approach using immutable images and startup configuration.

3.1 On managing configuration (and complexity) · 3.1.1 Your configuration management architecture · 3.1.2 Implementation choices · 3.2 Building our Spring Cloud configuration server · 3.2.1 Setting up the Spring Cloud Config Bootstrap class · 3.2.2 Using Spring Cloud configuration server with the filesystem · 3.3 Integrating Spring Cloud Config with a Spring Boot client · 3.3.1 Setting up the licensing service Spring Cloud Config server dependencies · 3.3.2 Configuring the licensing service to use Spring Cloud Config · 3.3.3 Wiring in a data source using Spring Cloud configuration server · 3.3.4 Directly Reading Properties using the @Value Annotation · 3.3.5 Using Spring Cloud configuration server with Git · 3.3.6 Refreshing your properties using Spring Cloud configuration server · 3.4 Protecting sensitive configuration information · 3.4.1 Download and install Oracle JCE jars needed for encryption · 3.4.2 Setting up an encryption key · 3.4.3 Encrypting and decrypting a property · 3.4.4 Configure microservices to use encryption on the client side · 3.5 Closing thoughts · 3.6 Summary

What you learn in chapter 3 →

Chapter 4: Chapter 4. On service discovery

This introduction explains service discovery and how it supports scaling and resilience in cloud-based microservices.

4.1 Where’s my service? · 4.2 On service discovery in the cloud · 4.2.1 The architecture of service discovery · 4.2.2 Service discovery in action using Spring and Netflix Eureka · 4.3 Building your Spring Eureka Service · 4.4 Registering services with Spring Eureka · 4.5 Using service discovery to look up a service · 4.5.1 Looking up service instances with Spring DiscoveryClient · 4.5.2 Invoking services with Ribbon-aware Spring RestTemplate · 4.5.3 Invoking services with Netflix Feign client · 4.6 Summary

What you learn in chapter 4 →

Chapter 5: Chapter 5. When bad things happen: client resiliency patterns with Spring Cloud and Netflix Hystrix

This introduction explains why slow or partially degraded services can exhaust client resources and cause cascading failures in microservice systems.

5.1 What are client-side resiliency patterns? · 5.1.1 Client-side load balancing · 5.1.2 Circuit breaker · 5.1.3 Fallback processing · 5.1.4 Bulkheads · 5.2 Why client resiliency matters · 5.3 Enter Hystrix · 5.4 Setting up the licensing server to use Spring Cloud and Hystrix · 5.5 Implementing a circuit breaker using Hystrix · 5.5.1 Timing out a call to the organization microservice · 5.5.2 Customizing the timeout on a circuit breaker · 5.6 Fallback processing · 5.7 Implementing the bulkhead pattern · 5.8 Getting beyond the basics; fine-tuning Hystrix · 5.8.1 Hystrix configuration revisited · 5.9 Thread context and Hystrix · 5.9.1 ThreadLocal and Hystrix · 5.9.2 The HystrixConcurrencyStrategy in action · 5.10 Summary

What you learn in chapter 5 →

Chapter 6: Chapter 6. Service routing with Spring Cloud and Zuul

This introduction explains why cross-cutting behaviors are difficult to implement across microservices and how a services gateway provides a central enforcement point.

6.1 What is a services gateway? · 6.2 Introducing Spring Cloud and Netflix Zuul · 6.2.1 Setting up the Zuul Spring Boot project · 6.2.2 Using Spring Cloud annotation for the Zuul service · 6.2.3 Configuring Zuul to communicate with Eureka · 6.3 Configuring routes in Zuul · 6.3.1 Automated mapping routes via service discovery · 6.3.2 Mapping routes manually using service discovery · 6.3.3 Manual mapping of routes using static URLs · 6.3.4 Dynamically reload route configuration · 6.3.5 Zuul and service timeouts · 6.4 The real power of Zuul: filters · 6.5 Building your first Zuul pre-filter generating correlation IDs · 6.5.1 Using the correlation ID in your service calls · 6.6 Building a post filter receiving correlation IDs · 6.7 Building a dynamic route filter · 6.7.1 Building the skeleton of the routing filter · 6.7.2 Implementing the run() method · 6.7.3 Forwarding the route · 6.7.4 Pulling it all together · 6.8 Summary

What you learn in chapter 6 →

Chapter 7: Chapter 7. Securing your microservices

This introduction explains layers of application security and how OAuth2 tokens support authentication across microservices without repeatedly presenting credentials.

7.1 Introduction to OAuth2 · 7.2 Starting small: using Spring and OAuth2 to protect a single endpoint · 7.2.1 Setting up the EagleEye OAuth2 authentication service · 7.2.2 Registering client applications with the OAuth2 service · 7.2.3 Configuring EagleEye users · 7.2.4 Authenticating the user · 7.3 Protecting the organization service using OAuth2 · 7.3.1 Adding the Spring Security and OAuth2 jars to the individual services · 7.3.2 Configuring the service to point to your OAuth2 authentication service · 7.3.3 Defining who and what can access the service · 7.3.4 Propagating the OAuth2 access token · 7.4 JavaScript Web Tokens and OAuth2 · 7.4.1 Modifying the authentication service to issue JavaScript Web Tokens · 7.4.2 Consuming JavaScript Web Tokens in your microservices · 7.4.3 Extending the JWT Token · 7.4.4 Parsing a custom field out of a JavaScript token · 7.5 Some closing thoughts on microservice security · 7.6 Use HTTPS/Secure Sockets Layer (SSL) for all service communication · 7.6 Summary · 7.7 Use a services gateway to access your microservices · 7.8 Zone your services into a public API and private API · 7.9 Limit the attack surface of your microservices by locking down un- nneeded network ports

What you learn in chapter 7 →

Chapter 8: Chapter 8. Event-driven architecture with Spring Cloud Stream

This introduction explains event-driven microservice communication and Spring Cloud Stream’s role in simplifying messaging.

8.1 The case for messaging, EDA, and microservices · 8.1.1 Using synchronous request-response approach to communicate state change · 8.1.2 Using messaging to communicate state changes between services · 8.1.3 Downsides of a messaging architecture · 8.2 Introducing Spring Cloud Stream · 8.2.1 The Spring Cloud Stream architecture · 8.3 Writing a simple message producer and consumer · 8.3.1 Writing the message producer in the organization service · 8.3.2 Writing the message consumer in the licensing service · 8.3.3 Seeing the message service in action · 8.4 A Spring Cloud Stream use case: distributed caching · 8.4.1 Using Redis to cache lookups · 8.4.2 Defining custom channels · 8.4.3 Bringing it all together: clearing the cache when a message is received · 8.5 Summary

What you learn in chapter 8 →

Chapter 9: Chapter 9. Distributed tracing with Spring Cloud Sleuth and Zipkin

This introduction explains the challenge of debugging distributed transactions and the roles of Sleuth, Papertrail, and Zipkin in tracing them.

9.1 Spring Cloud Sleuth and the correlation ID · 9.1.1 Adding Spring Cloud sleuth to licensing and organization · 9.1.2 Anatomy of a Spring Cloud Sleuth trace · 9.2 Log aggregation and Spring Cloud Sleuth · 9.2.1 A Spring Cloud Sleuth/Papertrail implementation in action · 9.2.2 Create a Papertrail account and configure a syslog connector · 9.2.3 Redirecting Docker output to Papertrail · 9.2.4 Searching for Spring Cloud Sleuth trace IDs in Papertrail · 9.2.5 Adding the correlation ID to the HTTP response with Zuul · 9.3 Distributed tracing with Open Zipkin · 9.3.1 Setting up the Spring Cloud Sleuth and Zipkin dependencies · 9.3.2 Configuring the services to point to Zipkin · 9.3.3 Installing and configuring a Zipkin server · 9.3.4 Setting tracing levels · 9.3.5 Using Zipkin to trace transactions · 9.3.6 Visualizing a more complex transaction · 9.3.7 Capturing messaging traces · 9.3.8 Adding custom spans · 9.4 Summary

What you learn in chapter 9 →

Chapter 10: Chapter 10. Deploying your microservices

This introduction explains why microservices need fast, automated deployment pipelines and outlines the properties of their build and runtime artifacts.

10.1 EagleEye: setting up your core infrastructure in the cloud · 10.1.1 Creating the PostgreSQL database using Amazon RDS · 10.1.2 Creating the Redis cluster in Amazon · 10.1.3 Creating an ECS cluster · 10.2 Beyond the infrastructure: deploying EagleEye · 10.2.1 Deploying the EagleEye services to ECS manually · 10.3 The architecture of a build/deployment pipeline · 10.4 Your build and deployment pipeline in action · 10.5 Beginning your build deploy/pipeline: GitHub and Travis CI · 10.6 Enabling your service to build in Travis CI · 10.6.1 Core build run-time configuration · 10.6.2 Pre-build tool installations · 10.6.3 Executing the build · 10.6.4 Tagging the source control code · 10.6.5 Building the microservices and creating the Docker images · 10.6.6 Pushing the images to Docker Hub · 10.6.7 Starting the services in Amazon ECS · 10.6.8 Kicking off the platform tests · 10.7 Closing thoughts on the build/deployment pipeline · 10.8 Summary

What you learn in chapter 10 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.