Micro-service processing method and apparatus, electronic device, and storage medium

By performing mapping transformations on remote interfaces and loading them into memory during microservice startup, the performance overhead in microservice calls is resolved, achieving efficient microservice processing.

CN115640143BActive Publication Date: 2026-03-20PING AN TECH (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-28
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

In existing microservice architectures, service calls made through the Feign component incur performance overhead, resulting in low processing efficiency.

Method used

When a microservice starts, the remote interface is converted based on the mapping relationship, and the conversion result is loaded into memory to avoid mapping matching when the actual call occurs.

Benefits of technology

It improves the processing efficiency and accuracy of microservices and reduces the performance loss of remote interface calls.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115640143B_ABST
    Figure CN115640143B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of artificial intelligence, and provides a micro-service processing method and device, electronic equipment and a storage medium, the method comprises the following steps: based on the merging relationship among a plurality of micro-services, the starting application packages of the plurality of micro-services are packed to obtain a plurality of target starting application packages; when it is detected that any one target starting application package is started, based on the mapping relationship between each micro-service and the deployed micro-service, the interface name of a remote interface in each micro-service is converted, and the conversion result is loaded into the memory; in response to the received HTTP request, loading data of a page is acquired; based on the loading data, a target micro-service is acquired from the memory, and other micro-service calls are executed based on the target micro-service. Through the conversion of the remote interface when the micro-service is started, the performance loss of the remote interface call is avoided, and the processing efficiency of the micro-service is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and in particular to a micro-service processing method and device, electronic equipment and storage medium. BACKGROUND

[0002] The ecological components of the micro-service architecture are very mature, and most of the existing application systems adopt the micro-service architecture design. Generally, services are split according to business or function, and are split into individual micro-services. Each micro-service is independently deployed and does not affect each other. The currently popular micro-service architecture includes spring cloud, and the key service calling method between services is completed through the feign component.

[0003] However, through the calling component feign between micro-services, dynamic proxy is used for conversion during calling, and the correct service is called according to the mapping relationship. This does not solve the problem from the source code level, and the mapping relationship is found only when the micro-service interface is actually called. This causes certain performance loss of remote interface calling and leads to low micro-service processing efficiency.

[0004] Therefore, it is necessary to propose a method for quickly processing micro-services. SUMMARY

[0005] In view of the above, it is necessary to propose a micro-service processing method, device, electronic equipment and storage medium. By converting the remote interface when the micro-service starts, the performance loss of remote interface calling is avoided, and the processing efficiency of the micro-service is improved.

[0006] A first aspect of the present application provides a micro-service processing method, the method comprising:

[0007] receiving a plurality of micro-services and a merging relationship between the plurality of micro-services;

[0008] packaging a start application package of the plurality of micro-services based on the merging relationship to obtain a plurality of target start application packages;

[0009] when detecting that any one of the target start application packages is started, reading a mapping relationship between each micro-service in the any one of the target start application packages and a deployed micro-service;

[0010] based on the mapping relationship between each micro-service and the deployed micro-service, converting an interface name of a remote interface in each micro-service, and loading the conversion result into the memory;

[0011] in response to the received HTTP request, obtaining page loading data;

[0012] obtaining a target microservice from the memory based on the loading data, and performing other microservice calls based on the target microservice.

[0013] Optionally, the reading of the mapping relationship between each microservice in the arbitrary target startup application package and the deployed microservice comprises:

[0014] executing first code in the arbitrary target startup application package;

[0015] reading the mapping relationship between each microservice and the deployed microservice from the configuration center based on the first code.

[0016] Optionally, the conversion of the interface name of the remote interface of each microservice based on the mapping relationship between each microservice and the deployed microservice comprises:

[0017] identifying the mapping relationship between each microservice and the deployed microservice;

[0018] identifying whether the interface name of the remote interface of each microservice needs to be converted according to the mapping relationship;

[0019] when it is identified that there is a merging relationship for the remote interface of each microservice, determining that the interface name of the remote interface of each microservice needs to be converted, and converting the interface name of the remote interface of each microservice into the interface name of the corresponding deployed microservice;

[0020] when it is identified that there is no merging relationship for the remote interface of each microservice, determining that the interface name of the remote interface of each microservice does not need to be converted.

[0021] Optionally, the obtaining of the target microservice from the memory based on the loading data comprises:

[0022] obtaining the service name of the loaded microservice from the loading data;

[0023] routing to the corresponding target microservice through the microservice gateway according to the service name of the microservice.

[0024] Optionally, the performing of other microservice calls based on the target microservice comprises:

[0025] extracting second code in the startup application package of the target microservice from the configuration center;

[0026] determining other microservices called by the target microservice according to the second code, and initiating calls based on the remote interface of the other microservices.

[0027] Optionally, before the performing of other microservice calls based on the target microservice, the method further comprises:

[0028] extracting remote interfaces of other microservices from a microservice list of the registration center;

[0029] identifying the remote interfaces of the other microservices according to a mapping relationship between the other microservices and the deployed microservices;

[0030] when it is identified that the remote interfaces of the other microservices have a merging relationship, obtaining a first IP address and a first service port corresponding to a service name of an original microservice of the other microservices;

[0031] replacing the first IP address and the first service port corresponding to the service name of the original microservice of the other microservices with a second IP address and a second service port corresponding to a service name of a deployed microservice.

[0032] Optionally, the method further comprises:

[0033] based on the merging relationship between the plurality of microservices, compiling a configuration file, and storing the configuration file to a configuration center.

[0034] A second aspect of the present application provides a microservice processing device, the device comprising:

[0035] a receiving module configured to receive a plurality of microservices and a merging relationship between the plurality of microservices;

[0036] a packaging module configured to package a start application package of the plurality of microservices based on the merging relationship, to obtain a plurality of target start application packages;

[0037] a reading module configured to read a mapping relationship between each microservice in any one of the target start application packages and a deployed microservice when it is detected that the any one of the target start application packages is started;

[0038] a conversion module configured to convert an interface name of a remote interface in each microservice based on the mapping relationship between each microservice and the deployed microservice, and load a conversion result into a memory;

[0039] an obtaining module configured to obtain loading data of a page in response to a received HTTP request;

[0040] a calling module configured to obtain a target microservice from the memory based on the loading data, and perform other microservice calling based on the target microservice.

[0041] A third aspect of the present application provides an electronic device, the electronic device comprising a processor and a memory, the processor being configured to implement the microservice processing method when executing a computer program stored in the memory.

[0042] The fourth aspect of the present application provides a computer readable storage medium, the computer readable storage medium stores a computer program, the computer program is executed by a processor to realize the micro-service processing method.

[0043] In summary, the micro-service processing method, device, electronic equipment and storage medium provided by the present application can promote the construction of smart city, and can be applied to the fields of smart building, smart security, smart community, smart life, Internet of Things, etc. By packing the start application package of the plurality of micro-services according to the merging relationship between the plurality of micro-services, the number of micro-services is reduced, and the waste of resources is reduced. When detecting that any one target start application package is started, based on the mapping relationship between each micro-service and the deployed micro-service, the remote interface in the micro-service start application package is scanned, and the interface name of the remote interface is converted. When actually calling, the remote interface of the micro-service does not need to be mapped and matched again, and can be directly called, without causing performance loss of the remote interface, improving the calling efficiency and accuracy of the micro-service remote interface, and further improving the processing efficiency of the micro-service. In response to the received HTTP request, the loading data of the page is obtained, the target micro-service is obtained from the memory based on the loading data, and other micro-service calls are performed based on the target micro-service. Without mapping and matching the remote interface, the performance loss of the remote interface call is avoided, and the processing efficiency of the micro-service is improved. BRIEF DESCRIPTION OF DRAWINGS

[0044] Figure 1 is a flow chart of the micro-service processing method provided by the first embodiment of the present application.

[0045] Figure 2 is a structural diagram of the micro-service processing device provided by the second embodiment of the present application.

[0046] Figure 3 is a structural diagram of the electronic equipment provided by the third embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the present application will be described in detail below in combination with the drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application.

[0049] Embodiment one

[0050] Figure 1 is a flowchart of the microservice processing method provided by the first embodiment of the present application.

[0051] In the present embodiment, the microservice processing method can be applied to an electronic device. For an electronic device that needs to be processed by microservices, the microservice processing function provided by the method of the present application can be integrated directly on the electronic device, or run in the form of a software development kit (SDK) in the electronic device.

[0052] The embodiments of the present application can acquire and process related data based on artificial intelligence technology. Artificial intelligence (AI) is the use of digital computers or computer-controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0053] The basic technology of artificial intelligence generally includes technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. The software technology of artificial intelligence mainly includes computer vision technology, robot technology, biometric technology, speech processing technology, natural language processing technology, and machine learning, deep learning, etc.

[0054] As shown in Figure 1 The microservice processing method specifically includes the following steps, and the order of the steps in the flowchart can be changed, and some steps can be omitted according to different requirements.

[0055] 101, receiving a plurality of microservices and a merging relationship between the plurality of microservices.

[0056] In the present embodiment, when a customer performs microservice processing, the customer sends message information of microservice processing through a client, wherein the message information of microservice processing contains a plurality of microservices and a merging relationship between the plurality of microservices, wherein the merging relationship is set by the customer based on actual requirements. For example, a customer's system has 10 microservices, which normally require 10 servers, but the customer currently has only 5 servers, so the customer needs to set the merging relationship of the 10 microservices according to project requirements, and perform merging processing on the 10 microservices according to the merging relationship, and finally deploy the 10 servers to 5 servers.

[0057] 102, packaging the start application package of the plurality of microservices based on the merging relationship to obtain a plurality of target start application packages.

[0058] In this embodiment, the target start application package is obtained by packing the start application packages of the plurality of microservices based on the merging relationship, wherein each target start application package can contain a start application package of one microservice or a start application package of a plurality of microservices after merging.

[0059] Further, the method further comprises:

[0060] Based on the merging relationship between the plurality of microservices, a configuration file is written and stored in a configuration center.

[0061] In this embodiment, the configuration file can be written for the plurality of microservices according to the merging relationship between the plurality of microservices.

[0062] For example, the merging relationship is that the microservice B and the microservice C are merged into the microservice X, the start application package of the microservice B and the start application package of the microservice C are merged according to the merging relationship, and the configuration is added to map the service name of the microservice B and the service name of the actually deployed microservice X, and to map the service name of the microservice C and the service name of the actually deployed microservice X, wherein the left side of the mapping is the service name of the original microservice, and the right side is the service name of the deployed microservice after merging, and the mapping relationship after the configuration is: microservice B: microservice X; microservice C: microservice X.

[0063] In this embodiment, the configuration file contains the mapping relationship, the merging relationship, the start application package, etc. of each microservice, and the above written configuration file is stored in the configuration center, so that the required data information can be directly pulled from the configuration center when the microservice is processed subsequently.

[0064] In other optional embodiments, the service name of the merged microservice does not necessarily need to use a new service name, and the service name of the original microservice before merging can be used, for example, the microservice A, the microservice B and the microservice C are merged, and the service name of the merged microservice can also be A, wherein the service name of the merged microservice depends on the code organization structure of the next step.

[0065] In this embodiment, the start application packages of the plurality of microservices are packed according to the merging relationship between the plurality of microservices, the number of microservices is reduced, the cost and resources of the customer are saved, especially for many small and medium-sized customers, the resources are saved, and the difficulty and complexity of subsequent operation and maintenance are also reduced.

[0066] 103. When any one of the target start application packages is detected to be started, the mapping relationship between each microservice in the any one of the target start application packages and the deployed microservice is read.

[0067] In the embodiment, since each target startup application package can include a startup application package of one microservice or a startup application package of multiple microservices combined, when any one target application startup package is detected to be started, all microservices in the target startup application package and the mapping relationship between each microservice and the deployed microservice need to be read to quickly determine whether each microservice is combined, so that the correct calling interface can be obtained when the microservice is called subsequently, and the accuracy of the microservice calling is improved.

[0068] In an optional embodiment, the reading of the mapping relationship between each microservice in the any one target startup application package and the deployed microservice includes:

[0069] executing first code in the any one target startup application package;

[0070] reading the mapping relationship between each microservice and the deployed microservice from a configuration center based on the first code.

[0071] In the embodiment, the first code refers to common code in the any one target startup application package, and the common code is general code, which is included in each microservice.

[0072] For example, the configuration center stores the mapping relationship between the microservice and the deployed microservice: microservice A: deployed microservice A; microservice B: deployed microservice X; microservice C: deployed microservice X; wherein the combined relationship is that the microservice B and the microservice C are combined to obtain the microservice X.

[0073] 104, based on the mapping relationship between each microservice and the deployed microservice, the interface name of the remote interface in each microservice is converted, and the conversion result is loaded into the memory.

[0074] In the embodiment, the memory can be a Spring bean container.

[0075] In an optional embodiment, the conversion of the interface name of the remote interface of each microservice based on the mapping relationship between each microservice and the deployed microservice includes:

[0076] identifying the mapping relationship between each microservice and the deployed microservice;

[0077] determining whether the interface name of the remote interface of each microservice needs to be converted according to the mapping relationship;

[0078] When it is identified that the remote interface of each microservice has a merging relationship, it is determined that the interface name of the remote interface of each microservice needs to be converted, and the interface name of the remote interface of each microservice is converted into the interface name of the corresponding deployed microservice.

[0079] Further, the identifying the mapping relationship between each microservice and the deployed microservice further includes:

[0080] When it is identified that the remote interface of each microservice has no merging relationship, it is determined that the interface name of the remote interface of each microservice does not need to be converted.

[0081] For example, when it is identified that the remote interface of microservice B has a merging relationship, the microservice B and microservice C are merged to obtain microservice X, and the interface name of the remote interface of the microservice B is converted into X according to the merging relationship.

[0082] In this embodiment, when the microservice is started, the remote interface in the microservice starting application package is scanned, and the interface name of the remote interface is converted, so that when the microservice is really called, mapping matching of the remote interface of the microservice is not needed, the microservice can be directly called, and the performance of the remote interface is not lost, the calling efficiency and accuracy of the microservice remote interface are improved, and the processing efficiency of the microservice is improved.

[0083] 105, in response to the received HTTP request, obtaining the loading data of the page.

[0084] In this embodiment, after the microservices are merged, the client sends an HTTP request when the client is used, wherein the HTTP request includes the loading data of the page, for example, when the client clicks the order button on the page, the loading data of the order button is obtained.

[0085] 106, based on the loading data, obtaining the target microservice from the memory, and based on the target microservice, performing other microservice calling.

[0086] In this embodiment, the target microservice refers to a microservice corresponding to the service name of the microservice in the loading data, and different loading data corresponds to different service names of microservices.

[0087] In an optional embodiment, the obtaining the target microservice from the memory based on the loading data includes:

[0088] Obtaining the service name of the loaded microservice from the loading data;

[0089] According to the service name of the microservice, the microservice gateway is routed to the corresponding target microservice.

[0090] In an optional embodiment, the executing other microservice calls based on the target microservice comprises:

[0091] extracting second code in a startup application package of the target microservice from the configuration center;

[0092] determining other microservices called by the target microservice according to the second code, and initiating a call based on remote interfaces of the other microservices.

[0093] In the embodiment, the second code refers to business logic code in a startup application package of each microservice, wherein the second code contains business logic, and other microservices called by each microservice can be known through the second code.

[0094] In an optional embodiment, before the executing other microservice calls based on the target microservice, the method further comprises:

[0095] extracting remote interfaces of the other microservices from a microservice list of the registration center;

[0096] identifying the remote interfaces of the other microservices according to a mapping relationship between the other microservices and the deployed microservices;

[0097] when it is identified that the remote interfaces of the other microservices have a merging relationship, obtaining a first IP address and a first service port corresponding to a service name of an original microservice of the other microservice;

[0098] replacing the first IP address and the first service port corresponding to the service name of the original microservice of the other microservice with a second IP address and a second service port corresponding to a service name of a deployed microservice.

[0099] For example, if the A microservice is an order microservice A, according to the business logic of the order microservice A, it can be known that the order microservice A generates an order and then starts to call an inventory microservice B. Before the order microservice calls the remote interface of the inventory microservice B, a bean instance of the inventory microservice B is obtained from a Spring bean memory, and when it is found from the bean instance that an interface name of the remote interface of the inventory microservice B is converted into an interface name of a deployed X microservice, an IP address and a service port of the deployed X microservice are extracted from a microservice list of the registration center, and the IP address and the service port of the inventory microservice are replaced with the IP address and the service port corresponding to the deployed X microservice. After the replacement, the deployed X microservice receives the call of the remote interface, successfully deducts the inventory, and returns an order service success.

[0100] In this embodiment, the remote interface is rewritten when the microservice is started, and no mapping matching is needed when the real call is made, avoiding the performance loss of remote interface call and improving the processing efficiency of the microservice.

[0101] In other optional embodiments, in order to realize the free merging and packaging between various microservices, the code of each microservice is split into three maven modules, specifically: cmpc-a-main / / only one startup class, which is only a shell; cmpc-a-service / / all business logic codes are in this; cmpc-a-remote-api / / all @FeignClient interfaces provided by the service to the outside, wherein the maven pom file of the main project references the service project, the service project references the remote-api project, and the main project is used to package and deploy the application package when starting.

[0102] Exemplarily, if microservice a and microservice c are to be merged and deployed, only a shell project cmpc-d-main needs to be built (cmpc-d-servcie and cmpc-d-remote-api modules are not needed), and the business modules of cmpc-a-service and cmpc-c-service are referenced in the maven pom file of cmpc-d-main. Microservice c can also be directly merged into microservice a, and only the cmpc-c-servie module needs to be referenced in the maven pom file of a-main. No matter which merging method is used, the original remote-api and service code and structure of each microservice do not need to be changed. When microservice b calls the FeignClien interface of microservice a, the actual deployed microservice d in the mapping configuration is found according to the microservice a name, then the IP address and service port corresponding to the microservice d are found from the registration center, and then the call is initiated.

[0103] In this embodiment, by splitting the code of each microservice into three maven modules, the free merging and packaging between various microservices is realized, and the diversity and flexibility of the merging and packaging are improved.

[0104] In summary, the microservice processing method provided in the embodiment reduces the number of microservices by packing the start application packages of the plurality of microservices according to the merging relationship among the plurality of microservices, and in turn reduces the waste of resources. When detecting that any one target start application package is started, based on the mapping relationship between each microservice and the deployed microservice, the remote interface in the microservice start application package is scanned, and the interface name of the remote interface is converted, so that when the microservice remote interface is actually called, mapping matching is not needed, and the microservice remote interface can be directly called, without causing performance loss of the remote interface, improving the calling efficiency and accuracy of the microservice remote interface, and in turn improving the processing efficiency of the microservice. In response to the received HTTP request, the loading data of the page is obtained, the target microservice is obtained from the memory based on the loading data, and other microservice calling is performed based on the target microservice, without mapping matching of the remote interface, avoiding performance loss of the remote interface calling, and improving the processing efficiency of the microservice.

[0105] Embodiment Two

[0106] Figure 2 is a structural diagram of a microservice processing apparatus provided in Embodiment Two of the present application.

[0107] In some embodiments, the microservice processing apparatus 20 can include a plurality of functional modules composed of program code segments. The program codes of each program segment in the microservice processing apparatus 20 can be stored in the memory of the electronic device and executed by the at least one processor to perform the functions of microservice processing (see Figure 1 Description).

[0108] In the embodiment, the microservice processing apparatus 20 can be divided into a plurality of functional modules according to the functions performed thereby. The functional modules can include a receiving module 201, a packing module 202, a writing module 203, a reading module 204, a conversion module 205, an obtaining module 206, and a calling module 207. The module referred to in the present application refers to a series of computer readable instruction segments that can be executed by at least one processor and can complete a fixed function, which are stored in the memory. In the embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0109] The receiving module 201 is configured to receive a plurality of microservices and a merging relationship among the plurality of microservices.

[0110] In the embodiment, when the client performs microservice processing, the client sends microservice processing message information through the client, wherein the microservice processing message information includes a plurality of microservices and a merging relationship between the plurality of microservices, wherein the merging relationship is set by the client based on actual requirements, for example, there are 10 microservices in the system of the client, and 10 servers are normally required, but the client currently has only 5 servers, so the merging relationship of the 10 microservices needs to be set according to the project requirements, and the 10 microservices are processed according to the merging relationship, and finally the 10 servers are deployed in the 5 servers.

[0111] The packaging module 202 is configured to package the start application packages of the plurality of microservices based on the merging relationship to obtain a plurality of target start application packages.

[0112] In the embodiment, the target start application package is obtained by packaging the start application packages of the plurality of microservices based on the merging relationship, wherein each target start application package can include a start application package of one microservice or a start application package of a plurality of microservices after merging.

[0113] The writing module 203 is configured to write a configuration file based on the merging relationship between the plurality of microservices, and store the configuration file in a configuration center.

[0114] In the embodiment, the configuration file can be written for the plurality of microservices according to the merging relationship between the plurality of microservices.

[0115] For example, the merging relationship is that the microservice B and the microservice C are merged into the microservice X, the start application package of the microservice B and the start application package of the microservice C are merged according to the merging relationship, and the configuration is added, the service name of the microservice B is mapped to the service name of the actually deployed microservice X, and the service name of the microservice C is mapped to the service name of the actually deployed microservice X, wherein the left side of the mapping is the service name of the original microservice, and the right side is the service name of the deployed microservice after merging, and the mapping relationship after configuration is: microservice B: microservice X; microservice C: microservice X.

[0116] In the embodiment, the configuration file includes the mapping relationship, the merging relationship, the start application package and the like of each microservice, and the above written configuration file is stored in the configuration center, so that when subsequent microservice processing is performed, the required data information can be directly pulled from the configuration center.

[0117] In other optional embodiments, the service name of the merged microservice does not necessarily need to use a new service name, and the original service name of the merged microservice can be used, for example, microservices A, B and C are merged, and the service name of the merged microservice can also be A, wherein the service name of the merged microservice depends on the code organization structure of the next step.

[0118] In this embodiment, by packaging the start application package of the plurality of microservices according to the merging relationship between the plurality of microservices, the number of microservices is reduced, helping customers to save costs and resources, especially many small and medium-sized customers, saving resources while reducing their subsequent operation and maintenance difficulty and complexity.

[0119] The reading module 204 is configured to read the mapping relationship between each microservice in the target start application package and the deployed microservice when any one target start application package is detected to start.

[0120] In this embodiment, since each target start application package can include a start application package of one microservice or a start application package of a plurality of merged microservices, when any one target application start package is detected to start, the mapping relationship between all microservices in the target start application package and each microservice and the deployed microservice needs to be read to quickly determine whether each microservice is merged, so as to facilitate subsequent microservice calling to obtain the correct calling interface and improve the accuracy of microservice calling.

[0121] In an optional embodiment, the reading module 204 reads the mapping relationship between each microservice in the target start application package and the deployed microservice, including:

[0122] Executing the first code in the target start application package;

[0123] Reading the mapping relationship between each microservice and the deployed microservice from the configuration center based on the first code.

[0124] In this embodiment, the first code refers to the common code in the target start application package, and the common code is a general code, which is included in each microservice.

[0125] For example, the configuration center stores the mapping relationship between the microservice and the deployed microservice: microservice A: deployed microservice A; microservice B: deployed microservice X; microservice C: deployed microservice X; wherein the merging relationship is that microservices B and C are merged to obtain microservice X.

[0126] The conversion module 205 is configured to convert the interface name of the remote interface in each microservice based on the mapping relationship between the microservice and the deployed microservice, and load the conversion result into the memory.

[0127] In this embodiment, the memory can be a Spring bean container.

[0128] In an optional embodiment, the conversion module 205 converts the interface name of the remote interface in each microservice based on the mapping relationship between the microservice and the deployed microservice, and the conversion includes:

[0129] identifying the mapping relationship between the microservice and the deployed microservice;

[0130] determining whether the interface name of the remote interface in each microservice needs to be converted according to the mapping relationship;

[0131] when it is identified that the remote interface in each microservice has a merging relationship, determining that the interface name of the remote interface in each microservice needs to be converted, and converting the interface name of the remote interface in each microservice into the interface name of the corresponding deployed microservice.

[0132] Further, the identification of the mapping relationship between the microservice and the deployed microservice further includes:

[0133] when it is identified that the remote interface in each microservice has no merging relationship, determining that the interface name of the remote interface in each microservice does not need to be converted.

[0134] For example, when it is identified that the remote interface in the microservice B has a merging relationship, the microservice B and the microservice C are merged to obtain the microservice X, and the interface name of the remote interface in the microservice B is converted into X according to the merging relationship.

[0135] In this embodiment, when the microservice is started, the remote interface in the microservice start application package is scanned, and the interface name of the remote interface is converted. When the remote interface is actually called, it does not need to be mapped and matched again, and can be directly called, which does not cause performance loss of the remote interface, improves the calling efficiency and accuracy of the microservice remote interface, and further improves the processing efficiency of the microservice.

[0136] The acquisition module 206 is configured to acquire the loading data of a page in response to a received HTTP request.

[0137] In this embodiment, after the microservices are merged, the client sends an HTTP request when the client is used, and the HTTP request includes the loading data of a page. For example, when the client clicks an order button on the page, the loading data of the order button is acquired.

[0138] The calling module 207 is configured to obtain a target microservice from the memory based on the loading data, and perform other microservice calls based on the target microservice.

[0139] In this embodiment, the target microservice refers to a microservice corresponding to a service name of a microservice in the loading data, and different loading data corresponds to different service names of microservices.

[0140] In an optional embodiment, the calling module 207 obtains the target microservice from the memory based on the loading data, including:

[0141] obtaining a service name of the loaded microservice from the loading data;

[0142] routing to the corresponding target microservice through a microservice gateway according to the service name of the microservice.

[0143] In an optional embodiment, the calling module 207 performs other microservice calls based on the target microservice, including:

[0144] extracting a second code in a startup application package of the target microservice from the configuration center;

[0145] determining other microservices called by the target microservice according to the second code, and initiating a call based on a remote interface of the other microservices.

[0146] In this embodiment, the second code refers to a business logic code in a startup application package of each microservice, wherein the second code contains business logic, and other microservices called by each microservice can be known through the second code.

[0147] In an optional embodiment, before the other microservice calls based on the target microservice are performed, a remote interface of the other microservice is extracted from a microservice list of the registration center; the remote interface of the other microservice is identified according to a mapping relationship between the other microservice and the deployed microservice; when it is identified that the remote interface of the other microservice has a merging relationship, a first IP address and a first service port corresponding to a service name of an original microservice of the other microservice are obtained; and the first IP address and the first service port corresponding to the service name of the original microservice of the other microservice are replaced with a second IP address and a second service port corresponding to a service name of the deployed microservice.

[0148] Exemplarily, if the A microservice is an order microservice A, according to the business logic of the order microservice A, it can be known that the order microservice A generates an order and then starts to call an inventory microservice B. Before the order microservice calls the remote interface of the inventory microservice B, a bean instance of the inventory microservice B is obtained from the Spring bean memory. When it is discovered from the bean instance that the interface name of the remote interface of the inventory microservice B is converted into the interface name of the deployed X microservice, the IP address and the service port of the deployed X microservice are extracted from the microservice list of the registration center, the IP address and the service port of the inventory microservice are replaced by the corresponding IP address and service port of the deployed X microservice, and after the replacement, the deployed X microservice receives the call of the remote interface, successfully deducts the inventory, and returns the order service success.

[0149] In the embodiment, the remote interface is rewritten when the microservice is started, and no mapping matching is needed when the real call is made, so that the performance loss of the remote interface call is avoided, and the processing efficiency of the microservice is improved.

[0150] In other optional embodiments, in order to realize the free merging and packaging between microservices, the code of each microservice is split into three maven modules, specifically: cmpc-a-main / / only one startup class, which is only a shell; cmpc-a-service / / all business logic codes are in this; cmpc-a-remote-api / / all @FeignClient interfaces provided by the a service, wherein the maven pom file of the main project references the service project, the service project references the remote-api project, and when the startup application package is packaged and deployed, the main project is used for packaging and deployment.

[0151] Exemplarily, if microservice a and microservice c are to be combined and deployed, only a shell project of cmpc-d-main (without cmpc-d-servcie and cmpc-d-remote-api modules) needs to be built, and the business modules of cmpc-a-service and cmpc-c-service are referenced in the maven pom file of cmpc-d-main. Microservice c can also be combined into microservice a, and only the cmpc-c-servie module needs to be referenced in the maven pom file of the a-main module. Regardless of the combination manner, the original remote-api and service code and structure of each microservice do not need to be changed. When microservice b calls the FeignClien interface of microservice a, the actual deployed microservice d is found according to the microservice a name in the mapping configuration, and then the IP address and service port corresponding to the microservice d are found from the registration center, and then the call is initiated.

[0152] In the embodiment, by splitting the code of each microservice into three maven modules, the free combination and packaging of various microservices is realized, and the diversity and flexibility of the combination and packaging are improved.

[0153] In summary, the microservice processing apparatus provided in the embodiment packages the start application packages of the plurality of microservices according to the combination relationship among the plurality of microservices, reduces the number of microservices, and further reduces the waste of resources. When any target start application package is detected to be started, based on the mapping relationship between each microservice and the deployed microservice, the remote interface in the microservice start application package is scanned, and the interface name of the remote interface is converted, so that the remote interface of the microservice does not need to be mapped and matched again when actually called, can be directly called, and the performance loss of the remote interface is avoided, the calling efficiency and accuracy of the microservice remote interface are improved, and the processing efficiency of the microservice is improved. In response to the received HTTP request, the loading data of the page is acquired, the target microservice is acquired from the memory based on the loading data, and other microservice calling is performed based on the target microservice, without mapping and matching the remote interface, the performance loss of the remote interface calling is avoided, and the processing efficiency of the microservice is improved.

[0154] Embodiment Three

[0155] Referring to Figure 3 The electronic device 3 includes a memory 31, at least one processor 32, at least one communication bus 33, and a transceiver 34.

[0156] Those skilled in the art should understand,Figure 3 The structure of the electronic device shown is not a limitation of the embodiments of the present application, and can be a bus type structure or a star type structure. The electronic device 3 can also include more or less other hardware or software, or different component arrangements than shown.

[0157] In some embodiments, the electronic device 3 is an electronic device capable of automatically performing numerical calculation and / or information processing according to pre-set or stored instructions. The hardware of the electronic device 3 includes, but is not limited to, a microprocessor, an application specific integrated circuit, a programmable gate array, a digital processor, an embedded device, and the like. The electronic device 3 can also include a client device, which includes, but is not limited to, any electronic product capable of human-computer interaction with a client through a keyboard, a mouse, a remote controller, a touchpad, a voice control device, and the like, such as a personal computer, a tablet computer, a smart phone, a digital camera, and the like.

[0158] It should be noted that the electronic device 3 is only an example, and other existing or future electronic products, such as those that can be adapted to the present application, should also be included within the scope of the present application and are hereby incorporated by reference.

[0159] In some embodiments, the memory 31 is used to store program codes and various data, such as the microservice processing apparatus 20 installed in the electronic device 3, and to achieve high-speed and automatic access to programs or data during the operation of the electronic device 3. The memory 31 includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electrically-erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk memories, a magnetic disk memory, a magnetic tape memory, or any other computer-readable medium capable of carrying or storing data.

[0160] In some embodiments, the at least one processor 32 can be composed of integrated circuits, for example, can be composed of a single packaged integrated circuit, or can be composed of multiple packaged integrated circuits of the same function or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, combinations of various control chips, etc. The at least one processor 32 is the control core (Control Unit) of the electronic device 3, which connects various components of the entire electronic device 3 through various interfaces and lines, and executes programs or modules stored in the memory 31 and calls data stored in the memory 31 to perform various functions and process data of the electronic device 3.

[0161] In some embodiments, the at least one communication bus 33 is configured to realize the connection and communication between the memory 31, the at least one processor 32, etc.

[0162] Although not shown, the electronic device 3 can also include a power supply (such as a battery) for powering various components. Optionally, the power supply can be logically connected to the at least one processor 32 through a power management device, so as to realize the functions of managing charging, discharging, and power consumption management, etc. through the power management device. The power supply can also include one or more direct current or alternating current power supplies, recharging devices, power supply fault detection circuits, power supply converters or inverters, power supply status indicators, etc. The electronic device 3 can also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described here.

[0163] It should be understood that the embodiments are only for illustration and are not limited in the scope of the patent application by the structure.

[0164] The integrated units in the form of software function modules described above can be stored in a computer readable storage medium. The software function modules described above are stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, an electronic device, or a network device, etc.) or a processor to execute part of the method described in each embodiment of the present application.

[0165] In further embodiments, in combination with Figure 2 , the at least one processor 32 can execute the operation device of the electronic device 3 and various application programs (such as the micro-service processing device 20) installed, program codes, etc., for example, the various modules described above.

[0166] The memory 31 stores program codes, and the at least one processor 32 can invoke the program codes stored in the memory 31 to perform relevant functions. For example, Figure 2 Each module described in the foregoing embodiments is program codes stored in the memory 31 and executed by the at least one processor 32, so as to realize the functions of the modules and achieve the purpose of micro-service processing.

[0167] For example, the program codes can be divided into one or more modules / units, which are stored in the memory 31 and executed by the processor 32 to complete the present application. The one or more modules / units can be a series of computer-readable instruction segments capable of completing a specific function, which are used to describe the execution process of the program codes in the electronic device 3. For example, the program codes can be divided into a receiving module 201, a packaging module 202, a writing module 203, a reading module 204, a conversion module 205, an obtaining module 206, and a calling module 207.

[0168] In an embodiment of the present application, the memory 31 stores a plurality of computer-readable instructions, which are executed by the at least one processor 32 to realize the functions of micro-service processing.

[0169] Specifically, the specific implementation method of the at least one processor 32 to the above instructions can refer to Figure 1 The description of related steps in corresponding embodiments will not be repeated here.

[0170] In several embodiments provided by the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely schematic, for example, the division of the modules is only a logical function division, and actual implementation can have another division manner.

[0171] The modules illustrated as separate components can or can not be physically separate, and the components illustrated as modules can or can not be physical units, which can be located in one place, or distributed on a plurality of network units. According to actual needs, some or all of the modules can be selected to achieve the purpose of the present embodiment.

[0172] In addition, each functional module in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically independently, or two or more units can be integrated in one unit. The above integrated unit can be realized in the form of hardware, or in the form of hardware plus software function module.

[0173] It is apparent to a person skilled in the art that the present application is not limited to the details of the above-described exemplary embodiments, but can be implemented in other concrete forms without departing from the spirit or essential characteristics of the present application. Therefore, the embodiments should be considered in all respects as illustrative and not restrictive, the scope of the present application being defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and range of equivalency of the claims are embraced therein. Any reference signs in the claims should not be construed as limiting the claims to the figures in which the reference signs are used. Further, it is apparent that the word "comprising" does not exclude other elements or steps not mentioned, and the singular does not exclude the plural. Multiple units or devices recited in the present application can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names and not to indicate any particular order.

[0174] Finally, it should be noted that the above embodiments are merely used to illustrate the technical solutions of the present application, rather than limit the present application. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced equivalently without departing from the spirit and scope of the present application.

Claims

1. A microservice processing method, characterized in that, The method includes: receiving multiple microservices and the merging relationships between the multiple microservices; Based on the merging relationship, the startup application packages of the multiple microservices are packaged to obtain multiple target startup application packages; When any target startup application package is detected to be starting, read the mapping relationship between each microservice in the target startup application package and the deployed microservice; Based on the mapping relationship between each microservice and the deployed microservice, the interface name of the remote interface in each microservice is converted, including: when it is found that there is a merging relationship between the remote interfaces of each microservice, it is determined that the interface name of the remote interface of each microservice needs to be converted, the interface name of the remote interface of each microservice is converted into the interface name of the corresponding deployed microservice, and the conversion result is loaded into memory; In response to received HTTP requests, retrieve the page loading data; Retrieving a target microservice from memory based on the loaded data includes: retrieving the target microservice from memory based on the loaded data; retrieving the service name of the loaded target microservice from the loaded data; routing to the corresponding target microservice through a microservice gateway based on the service name of the target microservice; and executing other microservice calls based on the target microservice.

2. The microservice processing method as described in claim 1, characterized in that, The step of reading the mapping relationship between each microservice in any target startup application package and the deployed microservices includes: Execute the first code in any of the target startup application packages; Based on the first code, the mapping relationship between each microservice and the deployed microservice is read from the configuration center.

3. The microservice processing method as described in claim 1, characterized in that, The process of converting the interface name of the remote interface of each microservice based on the mapping relationship between each microservice and the deployed microservices includes: Identify the mapping relationship between each microservice and the deployed microservices; Based on the mapping relationship, identify whether the interface name of the remote interface of each microservice needs to be converted; When it is determined that there is no merge relationship between the remote interfaces of each microservice, it is determined that the interface name of the remote interface of each microservice does not need to be converted.

4. The microservice processing method as described in claim 1, characterized in that, The process of executing other microservice calls based on the target microservice includes: Extract the second code from the startup application package of the target microservice from the configuration center; The second code determines other microservices that the target microservice calls, and initiates calls based on the remote interfaces of those other microservices.

5. The microservice processing method as described in claim 1, characterized in that, Before executing other microservice calls based on the target microservice, the method further includes: Extract remote interfaces of other microservices from the microservice list in the registry center; The remote interfaces of the other microservices are identified based on the mapping relationship between the other microservices and the deployed microservices; When a merging relationship is identified between the remote interfaces of the other microservices, the first IP address and first service port corresponding to the original service name of the other microservices are obtained. Replace the first IP address and first service port corresponding to the original service name of the other microservices with the second IP address and second service port corresponding to the service name of the deployed microservice.

6. The microservice processing method according to any one of claims 1 to 5, characterized in that, The method further includes: writing a configuration file based on the merging relationship between the multiple microservices, and storing the configuration file in a configuration file. center.

7. A microservice processing device, characterized in that, The device includes: The receiving module is used to receive multiple microservices and the merging relationship between the multiple microservices; The packaging module is used to package the startup application packages of the multiple microservices based on the merging relationship to obtain multiple target startup application packages; The reading module is used to read the mapping relationship between each microservice in the target startup application package and the deployed microservice when the startup of any target startup application package is detected. The conversion module is used to convert the interface name of the remote interface in each microservice based on the mapping relationship between each microservice and the deployed microservice. The conversion module includes: when it is found that there is a merging relationship between the remote interfaces of each microservice, determining that the interface name of the remote interface of each microservice needs to be converted, converting the interface name of the remote interface of each microservice into the interface name of the corresponding deployed microservice, and loading the conversion result into memory. The retrieval module is used to retrieve the page's loading data in response to received HTTP requests; The calling module is used to retrieve the target microservice from the memory based on the loaded data, including: retrieving the target microservice from the memory based on the loaded data; retrieving the service name of the loaded target microservice from the loaded data; routing to the corresponding target microservice through the microservice gateway according to the service name of the target microservice; and executing other microservice calls based on the target microservice.

8. An electronic device, characterized in that, The electronic device includes a processor and a memory, the processor being configured to execute a computer program stored in the memory to implement the microservice processing method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction, which, when executed by a processor, implements the microservice processing method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Micro-service configuration system, device and medium

    CN113918215A