Micro service communication in ABP VNEXT

Introduction

Service communication is an essential function in the microservice architecture , The efficiency of service communication determines the superiority of the microservice architecture. There are two commonly used microservice communication strategies, namely rpc and http. Among them, the gRpc framework represents the most users of rpc. Of course, there is also a service communication strategy in the abp vNext microservice architecture, which uses HTTP for service communication.

Comparison between gRpc and http

Although gRpc is efficient and safe, the related .net framework is really bloated and difficult to use. This flaw is found in .net core3.X It may be solved perfectly later. The abp vNext microservice architecture appeared before .net core3.0, so the flexible and convenient http was chosen for service communication. Although the http strategy efficiency in microservice communication is lower than gRpc, the efficiency of internal calls through the container service after packaging json is also leveraged. The biggest advantage of http as a service communication is that after the user requests the http api interface, the internal service will carry the user’s http header (identity information) when requesting other services. The abp vNext microservice architecture uses ids4 to integrate a unified authorization service. All interface authorizations are in the form of jwt-bearer. This method makes the identity and permission verification of the internal communication strategy of the http service simple and convenient. It can be said that “user’s request” –>Interface Identity and Authority Verification–>Microservice Interface Identity and Authority Verification” from the beginning to the end in one go, without constructing tokens or re-authenticating users during service communication. The basic communication effects of abp vNext’s microservices are as follows:

share pictures

Service Communication

abp vNext provides an internal communication gateway (InternalGateway ), all internal service interface calls are served through this gateway. The following will introduce how to call the microservice interface through the internal gateway.

step1: Reference AbpHttpClientIdentityModelModule, AbpIdentityHttpApiClientModule module

Add AbpHttpClientIdentityModelModule, AbpIdentityHttpApiClientModule module dependencies in ApplicationModule, the above modules are respectively in Volo.Abp.Http.Client. IdentityModel, Volo.Abp.Identity.HttpApi.Client assembly, you can also directly reference the nuget package.

step2: Inject application services

Take user application services as an example, construct injection IIdentityUserAppService in a microservice application service

private readonly IIdentityUserAppService _userAppService;

step3: Call the interface

Call the user application service interface in the application service interface:

var user = await _userAppService.GetAsync(per.UserID);

step4: Configure the remote service interface

Configure the remote service address in the microservice, the remote service is the internal gateway address.

Share pictures

Test interface

Share a picture

Although The interface query business is more complicated, and it is called through the remote service interface, but the postman test interface time is within 100ms, and overall performance is superior.

Summary

The above introduces the services in the abp vNext microservice architecture Communication and microservice interface invocation methods, the test shows that the abp vNext microservice communication performance is reliable, and the api interface distributed through the internal gateway requires identity and permission verification, which ensures the security of microservice communication. Summarizing the advantages of abp vNext service communication are as follows:

1. Simple. Through the above operations, it can be seen that the microservice interface call in abp vNext is very simple, just like ordinary storage calls.

2. Efficient. Although the service communication efficiency of the http method is lower than that of the pRpc framework, the http request speed after json packaging is also very impressive.

3. Security. Compared with the gRpc framework, the identity and authority will be verified when using http for service communication, which ensures the communication security of microservices.

Recently ABP released version 1.0, and friends who want to transform microservices feel like getting it.

Leave a Comment

Your email address will not be published.