Skip to main content

Microservices Patterns - With examples in Java

Page 291

261

The API gateway pattern

API COMPOSITION

An API gateway typically does more than simply reverse proxying. It might also implement some API operations using API composition. The FTGO API gateway, for example, implements the Get Order Details API operation using API composition. As figure 8.4 shows, the mobile application makes one request to the API gateway, which fetches the order details from multiple services. The FTGO API gateway provides a coarse-grained API that enables mobile clients to retrieve the data they need with a single request. For example, the mobile client makes a single getOrderDetails() request to the API gateway. Many API calls required FTGO backend services

Firewall

Order Service

Internet getOrder() iPhone/ Android consumer application

Delivery Service

getDelivery()

Accounting Service

getBill() getTicket()

Kitchen Service

FTGO backend services

Firewall LAN getOrder()

Order Service

Internet iPhone/ Android consumer application

getDelivery() getOrderDetails()

API gateway

getBill() Accounting Service

getTicket()

Lower-performance network

Delivery Service

One API call required

Kitchen Service

Higher-performance network

Figure 8.4 An API gateway often does API composition, which enables a client such as a mobile device to efficiently retrieve data using a single API request.


Turn static files into dynamic content formats.

Create a flipbook
Microservices Patterns - With examples in Java by Nicolas Cruz Carpio - Issuu