- Building Microservices with .NET Core 2.0(Second Edition)
- Gaurav Aroraa
- 382字
- 2021-07-02 20:13:03
Communication between microservices
In the preceding section, we separated our Order module into Order services and discussed how we can break down the foreign key relationship between ORDER and PRODUCT tables.
In a monolithic application, we have a single repository that queries the database to fetch the records from both ORDER and PRODUCT tables. However, in our upcoming microservice application, we will segregate repositories between Order service and Product service. With each service having its respective database, each one would access its own database only. Order service would only be able to access order Database, whereas Product service would be able to access product Database only. Order service should not be allowed to access product Database and vice versa.
We will discuss communication between microservices in Chapter 3, Integration Techniques and Microservices, in detail.
Refer to the following diagram:

In the preceding figure, we can see that our UI is interacting with Order Service and Product service via API gateway. Both the services are physically separated from each other and there is no direct interaction between these services. Communication performed in this manner is also referred to as communication that is based on the API Gateway Pattern.
The API gateway is nothing but a middle tier via which the UI can interact with the microservices. It also provides a simpler interface and makes the process of consuming these services simpler. It provides a different level of granularity to different clients as required (browser and desktop).
We can say that it provides coarse-grained APIs to mobile clients and fine-grained APIs to desktop clients, and it can use a high-performance network underneath its hood to provide some serious throughput.
The definition of granularity from Wikipedia is as follows (https://en.wikipedia.org/wiki/Granularity):
"Granularity is the extent to which a system is broken down into small parts, either the system itself or its description or observation. It is the extent to which a larger entity is subpided. For example, a yard broken into inches has a finer granularity than a yard broken into feet.
Coarse-grained systems consist of fewer, larger components than fine-grained systems; a coarse-grained description of a system regards large subcomponents while a fine-grained description regards smaller components of which the larger ones are composed."
- 復雜軟件設計之道:領域驅動設計全面解析與實戰
- Dynamics 365 Application Development
- Access 數據庫應用教程
- Spring Boot+Spring Cloud+Vue+Element項目實戰:手把手教你開發權限管理系統
- Java編程指南:基礎知識、類庫應用及案例設計
- Swift 3 New Features
- Web程序設計(第二版)
- Python時間序列預測
- GameMaker Essentials
- ActionScript 3.0從入門到精通(視頻實戰版)
- PHP 8從入門到精通(視頻教學版)
- Offer來了:Java面試核心知識點精講(框架篇)
- 網絡綜合布線與組網實戰指南
- 菜鳥成長之路
- PHP典型模塊與項目實戰大全