Spring Cloud Gateway— An Introduction
In this article, we will try to understand the fundamentals of Spring Cloud Gateway which represents one of the most important patterns in the Microservices Architecture — API Gateway. We will create sample implementations based on Spring Boot & Spring Cloud Gateway. This is the fifth part of our Spring Boot Microservices series.
API Gateway
Spring Cloud Gateway provides a library to build an API Gateway. This is the preferred gateway implementation provided by Spring Cloud. It's built with Spring 5, Spring Boot 2, and Project Reactor.
To understand the offerings of Spring Cloud Gateway we must understand the API Gateway pattern in detail. Let's assume, we are implementing the microservices architecture for our e-commerce system. One of the microservices in the system is Product Catalog Service, which is responsible to manage product lifecycle through — create, update, delete, and get operations. Let’s go through some common scenarios, we might come across —
Scenario 1 — Multiple Versions of Service
Our Product Catalog Service is updated with the new changes, but the updated service is not compatible with the mobile client.
Though we cannot achieve the service update completely, we can optimize it by running multiple versions in parallel. Our mobile client will continue using version-V1 while other clients will move to the version-V2.
Scenario 2 — Restricted Access
Our Product Catalog Service provides APIs to both read and write, the catalog data.
Our security team suggests to limit the access to write APIs — add, update, and delete, from the vendor…