Chapter 6. Service routing with Spring Cloud and Zuul

 

This chapter covers

  • Using a services gateway with your microservices
  • Implementing a service gateway using Spring Cloud and Netflix Zuul
  • Mapping microservice routes in Zuul
  • Building filters to use correlation ID and tracking
  • Dynamic routing with Zuul

In a distributed architecture like a microservices one, there will come a point where you’ll need to ensure that key behaviors such as security, logging, and tracking of users across multiple service calls occur. To implement this functionality, you’ll want these attributes to be consistently enforced across all of your 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 difficult to consistently implement these capabilities in each service being built. 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. (I personally am guilty of this.) Unfortunately, for those of us working in a heavily regulated industry, such as financial services or healthcare, showing consistent and documented behavior in your systems is often a key requirement for complying with government regulations.

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

sitemap