From 9a3971dcf63fe1281dddcc02ad88195d42b9cfcc Mon Sep 17 00:00:00 2001 From: ahmetfarukulu Date: Thu, 21 Nov 2024 16:22:54 +0300 Subject: [PATCH] Update microservice tutorial parts to standardize service naming and integrate Ordering with Catalog service --- docs/en/tutorials/microservice/part-01.md | 2 +- docs/en/tutorials/microservice/part-02.md | 4 +-- docs/en/tutorials/microservice/part-03.md | 6 ++-- docs/en/tutorials/microservice/part-04.md | 6 ++-- docs/en/tutorials/microservice/part-05.md | 4 +-- docs/en/tutorials/microservice/part-06.md | 40 ++++++++++++++++++++++- 6 files changed, 50 insertions(+), 12 deletions(-) diff --git a/docs/en/tutorials/microservice/part-01.md b/docs/en/tutorials/microservice/part-01.md index 9258c328a5..16409d3b7b 100644 --- a/docs/en/tutorials/microservice/part-01.md +++ b/docs/en/tutorials/microservice/part-01.md @@ -4,7 +4,7 @@ //[doc-nav] { "Next": { - "Name": "Creating the initial Products microservice", + "Name": "Creating the initial Catalog service", "Path": "tutorials/microservice/part-02" } } diff --git a/docs/en/tutorials/microservice/part-02.md b/docs/en/tutorials/microservice/part-02.md index 514f51626f..47ea5f0b1c 100644 --- a/docs/en/tutorials/microservice/part-02.md +++ b/docs/en/tutorials/microservice/part-02.md @@ -1,4 +1,4 @@ -# Microservice Tutorial Part 02: Creating the initial Catalog Microservice +# Microservice Tutorial Part 02: Creating the initial Catalog service ````json //[doc-nav] @@ -8,7 +8,7 @@ "Path": "tutorials/microservice/part-01" }, "Next": { - "Name": "Building the Catalog microservice", + "Name": "Building the Catalog service", "Path": "tutorials/microservice/part-03" } } diff --git a/docs/en/tutorials/microservice/part-03.md b/docs/en/tutorials/microservice/part-03.md index 949c8bb42f..1f9d55f2c0 100644 --- a/docs/en/tutorials/microservice/part-03.md +++ b/docs/en/tutorials/microservice/part-03.md @@ -1,14 +1,14 @@ -# Microservice Tutorial Part 03: Building the Catalog Microservice +# Microservice Tutorial Part 03: Building the Catalog service ````json //[doc-nav] { "Previous": { - "Name": "Creating the initial Catalog Microservice", + "Name": "Creating the initial Catalog service", "Path": "tutorials/microservice/part-02" }, "Next": { - "Name": "Creating the initial Ordering Microservice", + "Name": "Creating the initial Ordering service", "Path": "tutorials/microservice/part-04" } } diff --git a/docs/en/tutorials/microservice/part-04.md b/docs/en/tutorials/microservice/part-04.md index a77037ebbc..02a49ca85a 100644 --- a/docs/en/tutorials/microservice/part-04.md +++ b/docs/en/tutorials/microservice/part-04.md @@ -1,14 +1,14 @@ -# Microservice Tutorial Part 04: Creating the initial Ordering Microservice +# Microservice Tutorial Part 04: Creating the initial Ordering service ````json //[doc-nav] { "Previous": { - "Name": "Building the Catalog Microservice", + "Name": "Building the Catalog service", "Path": "tutorials/microservice/part-03" }, "Next": { - "Name": "Building the Ordering module", + "Name": "Building the Ordering service", "Path": "tutorials/microservice/part-05" } } diff --git a/docs/en/tutorials/microservice/part-05.md b/docs/en/tutorials/microservice/part-05.md index 0ad81547f3..3b40a9a99e 100644 --- a/docs/en/tutorials/microservice/part-05.md +++ b/docs/en/tutorials/microservice/part-05.md @@ -1,10 +1,10 @@ -# Microservice Tutorial Part 05: Building the Ordering module +# Microservice Tutorial Part 05: Building the Ordering service ````json //[doc-nav] { "Previous": { - "Name": "Creating the initial Ordering Microservice", + "Name": "Creating the initial Ordering service", "Path": "tutorials/microservice/part-04" }, "Next": { diff --git a/docs/en/tutorials/microservice/part-06.md b/docs/en/tutorials/microservice/part-06.md index 476d2e6a9e..5b78a4b436 100644 --- a/docs/en/tutorials/microservice/part-06.md +++ b/docs/en/tutorials/microservice/part-06.md @@ -4,7 +4,7 @@ //[doc-nav] { "Previous": { - "Name": "Building the Ordering module", + "Name": "Building the Ordering service", "Path": "tutorials/microservice/part-05" }, "Next": { @@ -14,3 +14,41 @@ } ```` +In the previous part, we implemented the functionality of the Ordering microservice. However, when listing orders, we need to display the product name instead of the product ID. To achieve this, we must call the Catalog service to retrieve the product name for each order item. + +In this section, we will integrate the Ordering microservice with the Catalog service using HTTP API calls. + +## The Need for the Integration Services + +In a microservices architecture, each service is responsible for its own data and business logic. However, services often need to communicate with each other to fulfill their responsibilities. This communication can be synchronous or asynchronous, depending on the requirements. + +![web-orders-page](images/web-orders-page.png) + +In our case, the Ordering service needs to display the product name instead of the product ID. To achieve this, we need to call the Catalog service to retrieve the product details based on the product ID. This is a typical example of a synchronous communication pattern between microservices. As a solution to that problem, we will use an [integration service](../../framework/api-development/integration-services.md) that will handle the communication with the Catalog service. Integration service concept in ABP is designed for request/response style inter-module (in modular applications) and inter-microservice (in distributed systems) communication. + +## Creating a Products Integration Service + +First, we need to create a service that will handle the communication with the Catalog service. This service will be responsible for fetching the product details based on the product ID. + +### Defining the `IProductIntegrationService` Interface + +Open the `CloudCrm.CatalogService` .NET solution in your IDE. Locate the `CloudCrm.CatalogService.Contracts` project, and create a new folder named `Integration` within the `Services` folder. Inside this folder, add a new interface named `IProductIntegrationService` with the following code: + +```csharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using CloudCrm.CatalogService.Products; +using Volo.Abp; +using Volo.Abp.Application.Services; + +namespace CloudCrm.CatalogService.Services.Integration; + +[IntegrationService] +public interface IProductIntegrationService : IApplicationService +{ + Task> GetProductsByIdsAsync(List ids); +} +``` + +`IProductIntegrationService` is very similar to a typical [application service](../../framework/architecture/domain-driven-design/application-services.md). The only difference is that it is marked with the `[IntegrationService]` attribute. This attribute is used to identify the service as an integration service, which allows ABP to handle the communication between services. ABP behave differently for them (for example, ABP doesn't expose [integration services](../../framework/api-development/integration-services.md) as HTTP APIs by default if you've configured the [Auto API Controllers](../../framework/api-development/auto-controllers.md) feature) \ No newline at end of file