8 Service routing with Spring Cloud Gateway

 

This chapter covers

  • Using a service gateway with your microservices
  • Implementing a service gateway using Spring Cloud API Gateway
  • Mapping microservice routes in the gateway
  • Building filters to use correlation ID and tracking

In a distributed architecture like a microservices one, there will come the point where we’ll need to ensure that critical behaviors such as security, logging, and tracking of users across multiple service calls occur. To implement this functionality, we’ll want these attributes to be consistently enforced across all of our services without the need for each individual development team to build their own solutions. While it’s possible to use a common library or framework to assist with building these capabilities directly in an individual service, doing so has three implications.

First, it’s challenging to implement these capabilities in each service consistently. Developers are focused on delivering functionality, and in the whirlwind of day-to-day activity, they can easily forget to implement service logging or tracking unless they work in a regulated industry where it’s required.

8.1           What is a services gateway?

8.2           Introducing Spring Cloud Gateway

8.2.1   Setting up the Gateway Spring Boot project

8.2.2   Configuring the Spring Cloud Gateway to communicate with Eureka

8.3           Configuring routes in Spring Cloud Gateway

8.3.1   Automated mapping of routes via service discovery

8.3.2   Mapping routes manually using service discovery

8.3.3   Dynamically reload route configuration

8.3.4   Spring Cloud Gateway and service timeouts

8.4           The real power of the Spring Cloud Gateway: predicate and filters factories

8.4.1   Built-in Predicates Factories

8.4.2   Built-in Filters Factories

8.4.3   Custom Filters

8.5           Building the pre-filter

8.5.1   Using the correlation ID in the services

8.6           Building a post filter receiving correlation IDs

8.7           Summary

sitemap