Micro-service calling method and device, server and storage medium
By building a transaction configuration database and a global addressing view database, using transaction codes and publishing environment identifiers to quickly locate target service instances, the problem of inefficiency of microservice calls in complex cluster environments is solved, and efficient microservice calls are achieved.
Patent Information
- Application Number
- CN202411161298.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-08-22
AI Technical Summary
Existing microservice calling methods are difficult to accurately address microservices in complex cluster environments, resulting in inefficient call.
By building a transaction configuration database, a global addressing view database and a consumption transaction code database, the transaction code and publishing environment identifier are used to quickly locate and call target service instances, ensuring that microservice call requests can be processed in a timely manner.
Improve the efficiency and processing efficiency of microservice call requests, ensure that target service instances can be accurately positioned in complex cluster environments, and reduce call errors.
Smart Images

Figure CN119149191A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of microservice technology, and in particular to a microservice calling method, device, server and storage medium. Background Art
[0002] Microservices refer to applications that are composed of multiple smaller, loosely coupled services. Based on the loose coupling between services in microservices, microservices have the advantages of independent deployment, easy code update, and flexible configuration, making microservices suitable for environments with many services, complex call relationships, and diverse operating frameworks, such as distributed systems. Different types of services can be implemented by calling microservices.
[0003] Existing microservice calling methods, such as the load balancing calling method in microservices, can adopt the ideas of consumer service and provider service to provide calling interface services in an annotation injection manner.
[0004] However, due to the large number of interfaces in microservices and the complex cluster environment, the above-mentioned calling methods between microservices may fail to accurately address the microservice cluster environment or call the wrong microservice, thus failing to implement microservice calls, resulting in low microservice calling efficiency. Summary of the invention
[0005] The present application provides a microservice calling method, device, server and storage medium to solve the problem of low microservice calling efficiency in the prior art.
[0006] In a first aspect, the present application provides a microservice calling method, comprising:
[0007] In response to receiving the configuration information sent by each microservice, a corresponding database is configured according to the configuration information of each microservice, and the corresponding database is sent to each microservice; the database includes at least one of a transaction configuration database, a global addressing view database, and a consumption transaction code database, and the consumption transaction code database includes a consumption transaction code list of each microservice;
[0008] In response to receiving a microservice call request, determining call information corresponding to the microservice call request; wherein the call information includes a first microservice identifier, a second microservice identifier, and a first transaction code; the first microservice identifier is used to indicate a first microservice, and the second microservice identifier is used to indicate a second microservice;
[0009] If the first transaction code exists in the global addressing view database and the first transaction code exists in the consumption transaction code list of the first microservice, obtaining a target publishing environment identifier corresponding to the first transaction code from the global addressing view database;
[0010] Acquire registration component information corresponding to the target publishing environment identifier from the transaction configuration database, and address a target service instance corresponding to the first transaction code in the second microservice based on the registration component information, so as to process the microservice call request through the target service instance;
[0011] Receive the processing result of the target service instance sent by the second microservice, and send it to the first microservice.
[0012] In a possible design, the global addressing view database includes the global addressing view data of each of the microservices, and the global addressing view data of each of the microservices includes at least one transaction code to be served; the consumption transaction code list includes at least one transaction code to be consumed; wherein the transaction code to be served is used to indicate the transaction code for providing the service, and the transaction code to be consumed is used to indicate the transaction code for the service to be called;
[0013] When the first transaction code exists in the global addressing view database and the first transaction code exists in the consumption transaction code list of the first microservice, acquiring the target publishing environment identifier corresponding to the first transaction code from the global addressing view database includes:
[0014] Match the first transaction code among multiple transaction codes to be called in the consumption transaction code list of the first microservice;
[0015] When there is a transaction code to be called that matches the first transaction code in the consumption transaction code list of the first microservice, the first transaction code is matched in at least one transaction code to be served of the second microservice in the global addressing view database;
[0016] In the global addressing view database, when there is a transaction code to be serviced that matches the first transaction code in at least one transaction code to be serviced of the second microservice, a target release identifier corresponding to the first transaction code is obtained from the global addressing view database.
[0017] In a possible design, the global addressing view database further includes a microservice identifier of each microservice and a publishing environment identifier corresponding to each transaction code to be served; the transaction configuration database includes transaction configuration data of each microservice, and the transaction configuration data includes the microservice identifier of the microservice, multiple transaction codes of the microservice, and at least one resource environment information of the microservice; each resource environment information includes an environment identifier, a name of a registration component corresponding to the environment identifier, and a cluster address of the registration component; the multiple transaction codes of the microservice include each of the transaction codes to be served of the microservice;
[0018] When, in the global addressing view database, there is a transaction code to be serviced that matches the first transaction code in at least one transaction code to be serviced of the second microservice, acquiring a target release identifier corresponding to the first transaction code from the global addressing view database includes:
[0019] In the global addressing view database, when there is a transaction code to be served matching the first transaction code in at least one transaction code to be served of the second microservice, determining the transaction code to be served matching the first transaction code as the target transaction code to be served;
[0020] A publishing environment identifier corresponding to the target transaction code to be serviced is obtained from the global addressing view database as a target publishing identifier corresponding to the first transaction code.
[0021] In a possible design, the transaction configuration database includes at least one resource environment information of each of the microservices, and each of the resource environment information includes an environment identifier, a name of a registration component corresponding to the environment identifier, and a cluster address of the registration component;
[0022] The step of acquiring registration component information corresponding to the target publishing environment identifier from the transaction configuration database, and addressing a target service instance corresponding to the first transaction code in the second microservice based on the registration component information to process the microservice call request through the target service instance includes:
[0023] In the transaction configuration database, searching for an environment identifier that matches the target publishing environment identifier as the target environment identifier;
[0024] In the transaction configuration database, determining the name and cluster address of the registration component corresponding to the target environment identifier as the registration component information corresponding to the target publishing environment identifier, wherein the registration component information includes the name and cluster address of the registration component;
[0025] Determine the registration component corresponding to the name and cluster address of the registration component as the target registration address, and in the target address, determine each service instance corresponding to the second microservice based on the second microservice identifier; wherein the target address stores multiple service instances registered by each of the microservices;
[0026] Determine at least one healthy service instance corresponding to the first transaction code from each service instance of the second microservice in the target registration component, and send a microservice call request to each of the healthy service instances; the healthy service instance is used to indicate a service instance capable of processing the call request;
[0027] In response to receiving feedback information from the healthy service instance, determining that the healthy service instance corresponding to the feedback information is a target service instance, and sending a processing instruction to the target service instance, wherein the processing instruction is used to control the target service instance to process the microservice call request; wherein the feedback information is used to indicate that the service instance is in an idle state.
[0028] In a possible design, after the response to receiving the microservice call request and determining the call information corresponding to the microservice call request, the method further includes:
[0029] When there is no transaction code to be served matching the first transaction code in the global addressing view database, and / or there is no transaction code to be called matching the first transaction code in the consumption transaction code list of the first microservice, a call failure message is generated;
[0030] The call failure information is sent to the first microservice; the call failure information is used to prompt the first microservice that the microservice call request has not been successfully called.
[0031] In one possible design, the configuration information includes at least one of transaction configuration data, global addressing view data, and consumption transaction code data;
[0032] Correspondingly, in response to receiving the configuration information sent by each microservice, configuring the corresponding database according to the configuration information of each microservice, and sending the corresponding database to each microservice, includes:
[0033] In response to receiving the configuration information sent by each of the microservices, constructing the transaction configuration database based on the transaction configuration data in the configuration information of each of the microservices;
[0034] Building the global addressing view database based on the global addressing view data in the configuration information of each of the microservices;
[0035] Based on the consumption transaction code data in the configuration information of each microservice, a consumption transaction code list corresponding to each microservice is constructed; wherein the consumption transaction code data includes multiple transaction codes of at least one microservice;
[0036] The transaction configuration database and the global addressing view database are sent to each of the microservices, and a consumption transaction code list corresponding to each of the microservices is sent to each of the microservices respectively.
[0037] In a possible design, in response to receiving a microservice call request, determining call information corresponding to the microservice call request includes:
[0038] In response to receiving the microservice call request, parsing the microservice call request, obtaining a first microservice carried in the microservice call request, and determining a first microservice corresponding to the first microservice identifier;
[0039] A second microservice identifier and a first transaction code carried in the microservice call request are obtained, and a second microservice corresponding to the second microservice identifier is determined.
[0040] In a second aspect, the present application provides a microservice calling device, comprising:
[0041] A database configuration module, configured to, in response to receiving configuration information sent by each microservice, configure a corresponding database according to the configuration information of each microservice, and send the corresponding database to each microservice; the database includes at least one of a transaction configuration database, a global addressing view database, and a consumption transaction code database, and the consumption transaction code database includes a consumption transaction code list of each microservice;
[0042] A call information determination module, configured to determine, in response to receiving a microservice call request, call information corresponding to the microservice call request; wherein the call information includes a first microservice identifier, a second microservice identifier, and a first transaction code; the first microservice identifier is used to indicate a first microservice, and the second microservice identifier is used to indicate a second microservice;
[0043] an environment identifier acquisition module, configured to acquire a target publishing environment identifier corresponding to the first transaction code from the global addressing view database if the first transaction code exists in the global addressing view database and the first transaction code exists in the consumption transaction code list of the first microservice;
[0044] a request processing module, configured to obtain registration component information corresponding to the target publishing environment identifier from the transaction configuration database, and address a target service instance corresponding to the first transaction code in the second microservice based on the registration component information, so as to process the microservice call request through the target service instance;
[0045] A sending module is used to receive the processing result of the target service instance sent by the second microservice, and send it to the first microservice.
[0046] In a third aspect, an embodiment of the present application provides a server, comprising: at least one processor and a memory; the memory stores computer execution instructions; the at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the microservice calling method described in the first aspect and various possible designs of the first aspect.
[0047] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the microservice calling method described in the first aspect and various possible designs of the first aspect is implemented.
[0048] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the microservice calling method described in the first aspect and various possible designs of the first aspect.
[0049] The microservice calling method, device, server and storage medium provided in the present application configure the corresponding transaction configuration database, the global addressing view database and at least one database in the consumption transaction code list of each microservice according to the configuration information of each microservice in response to receiving the configuration information sent by each microservice. In response to receiving the microservice calling request, the calling information such as the first microservice, the second microservice and the first transaction code corresponding to the microservice calling request is determined. When the first transaction code exists in the global addressing view database and the consumption transaction code list of the first microservice exists, the target publishing environment identifier corresponding to the first transaction code is obtained from the global addressing view database. The registration component information corresponding to the target publishing environment identifier is obtained from the transaction configuration database, and the target service instance corresponding to the first transaction code is addressed in the second microservice based on the registration component information, so as to process the microservice calling request based on the target service instance. The processing result of the target service instance fed back by the second microservice is received and sent to the first microservice. In this way, the resource environment of the provider microservice can be quickly located based on the target publishing environment identifier, and the corresponding target service instance can be quickly found from the provider microservice based on the transaction code, and the microservice call request can be processed through the target service instance in a timely manner, thereby improving the calling efficiency and processing efficiency of the microservice call request. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0051] Figure 1 It is an application scenario diagram of the microservice calling method of the prior art;
[0052] Figure 2 An architectural diagram of a microservice invocation system provided in an embodiment of the present application;
[0053] Figure 3 The process of the microservice calling method provided in the embodiment of the present application Figure 1 ;
[0054] Figure 4 The process of the microservice calling method provided in the embodiment of the present application Figure 2 ;
[0055] Figure 5 The process of the microservice calling method provided in the embodiment of the present application Figure 3 ;
[0056] Figure 6 A schematic diagram of an application scenario of the microservice calling method provided in an embodiment of the present application;
[0057] Figure 7The process of the microservice calling method provided in the embodiment of the present application Figure 4 ;
[0058] Figure 8 The process of the microservice calling method provided in the embodiment of the present application Figure 5 ;
[0059] Fig. 9 A schematic diagram of the structure of a microservice invocation device provided in an embodiment of the present application;
[0060] Fig.10 A schematic diagram of the structure of a server provided in an embodiment of the present application.
[0061] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0062] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0063] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data involved shall comply with the provisions of relevant laws and regulations and shall not violate public order and good morals.
[0064] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0065] Terminology explanation:
[0066] Microservices are applications that are composed of multiple smaller, loosely coupled services. Microservices are characterized by loose coupling.
[0067] The service identifier is used to indicate the unique identity of the microservice. Each microservice has multiple services, each of which includes a unique transaction code. Each microservice can include multiple sets of resource environments, each of which includes a set of resource environment information.
[0068] A service instance is used to provide services, and each service may include multiple service instances.
[0069] The transaction code is used to indicate the unique identity of the service. For example, the transaction code for the delete order service is JY001, and the transaction code for the add order service is JY002.
[0070] Resource environment information is used to indicate the relevant information of the resource environment where the microservice is deployed. A set of resource environment information includes but is not limited to an environment identifier, the name of the registered component, and the cluster address of the registered component.
[0071] The environment identifier is used to indicate the unique identity of the resource environment;
[0072] The registration component is used to store one or more service instances in the resource environment;
[0073] The cluster address is used to indicate the cluster domain name of the registered component, including the IP address and port of the registered component.
[0074] Recently, the total volume of transactions in various industries has shown an increasing trend, and the types of transactions are becoming more and more diverse, such as the financial industry and the clothing industry. The traditional monolithic architecture service system can no longer meet the transaction needs of the above industries, and is gradually transforming to a distributed architecture system. Based on the growth of the total volume and types of transactions, the number of services, components, and machines in the distributed system has also shown an increasing trend, making the call relationship in the distributed system more complex. Based on the characteristics of loose coupling between services in microservices, microservices have the advantages of separate deployment, easy code update, and flexible configuration, making microservices suitable for environments with many services, complex call relationships, and diverse operating frameworks, such as distributed systems. Various types of services can be realized by calling microservices. The existing calling methods between microservices mainly adopt the ideas of consumer services and provider services, and provide calling interface services in the form of annotation injection.
[0075] Figure 1 The following is a schematic diagram of an application scenario of a microservice calling method in the prior art.
[0076] See also Figure 1 ,The calling method between microservices in the existing technology is mainly the consumer microservice (such as Figure 1 The microservice A shown in Figure 1) provides a provider microservice (such as Figure 1 The microservice B shown in FIG. 1 sends a microservice call request (such as Figure 1 ), to find the corresponding target service from multiple interfaces of the provider microservice.
[0077] However, due to the large number of services in microservices, the large number of corresponding interfaces and the complex cluster environment, the above-mentioned calling method between microservices cannot accurately address the microservice cluster environment or call the wrong microservice, thus failing to implement microservice calls, resulting in low microservice calling efficiency.
[0078] In response to the above problems, an embodiment of the present application provides a microservice calling method, which is applied to a server, and the method includes: in response to receiving configuration information sent by each microservice, configuring the corresponding transaction configuration database, the global addressing view database, and at least one database in the consumption transaction code list of each microservice according to the configuration information of each microservice. In response to receiving a microservice calling request, determining the calling information such as the first microservice, the second microservice, and the first transaction code corresponding to the microservice calling request. When the first transaction code exists in the global addressing view database and the consumption transaction code list of the first microservice, obtaining the target publishing environment identifier corresponding to the first transaction code from the global addressing view database. Obtaining the registration component information corresponding to the target publishing environment identifier from the transaction configuration database, addressing the target service instance corresponding to the first transaction code in the second microservice based on the registration component information, so as to process the microservice calling request based on the target service instance. Receive the processing result of the target service instance fed back by the second microservice, and send it to the first microservice. In this way, the resource environment of the provider microservice can be quickly located based on the target publishing environment identifier, and the corresponding target service instance can be quickly found from the provider microservice based on the transaction code, and the microservice call request can be processed through the target service instance in a timely manner, thereby improving the calling efficiency and processing efficiency of the microservice call request.
[0079] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0080] Figure 2 The present invention is an architectural diagram of a microservice calling system applicable to an embodiment of the present application.
[0081] like Figure 2 As shown, the microservice call system includes: microservice 1, microservice 2, and server 3. Among them, microservice 1 is deployed with integration agent A1 (agent), and microservice 2 is deployed with integration agent A2 (agent). The integration agent of each microservice is connected to server 3. Each microservice has multiple resource environments, and each resource environment has a unique corresponding registration component. Figure 1Only one resource environment and one registration component corresponding to the resource environment are shown. Each microservice includes multiple services ( Figure 1 Only 5 services are shown in each microservice. Figure 1 In the figure, services are represented by solid dots. Multiple services in each microservice are registered in the registration component.
[0082] The server 3 includes a data sending component 4 and a database 5 (data server).
[0083] The database 5 is used to store at least one of a transaction configuration database 5, a global addressing view database 5, and a consumption transaction code database 5. The consumption transaction code database 5 includes a consumption transaction code list for each microservice. Figure 1 Only the consumption transaction code list LB1 of microservice 1 and the consumption transaction code list LB2 of microservice 2 are shown.
[0084] Among them, the data sending component 4 is used to read various data (including but not limited to one or more of consumption transaction code list data, transaction configuration data and global addressing view data) from the server 3, and send the transaction configuration database 5 and the global addressing view database 5 to microservice 1 and microservice 2 respectively, send the consumption transaction code list LB1 of microservice 1 to microservice 1, and send the consumption transaction code list LB2 of microservice 2 to microservice 2.
[0085] In the scenario where microservice 1 calls microservice 2, microservice 1 is used to send a microservice call request to server 3 through integration agent A1 (such as Figure 1 (indicated by the dashed curved arrow in the middle).
[0086] The server 3 is used to determine the corresponding service 2 and the first transaction code based on the microservice call request. When the first transaction code exists in the global addressing view database and in the consumption transaction code list of the microservice 1, the server 3 obtains the registration component information corresponding to the first transaction code from the transaction configuration database 5, and addresses the target service instance corresponding to the first transaction code from the above registration component information through the integration agent A2 of the microservice 2.
[0087] Microservice 2 is used to process the microservice call request through the target service instance, and feed back the processing result of the target service instance to server 3 through integration agent 2.
[0088] Server 3 is also used to receive the processing result of the target service instance fed back by microservice 2, and send the above feedback result to microservice 1 (such as Figure 1 (indicated by the solid curved arrow in the middle).
[0089] based on Figure 2The microservice calling system shown, the embodiment of the present application also provides a microservice calling method. Figure 3 Flow chart of the microservice calling method provided in the embodiment of the present application. Figure 3 As shown, the microservice calling method includes:
[0090] S101. In response to receiving configuration information sent by each microservice, configure a corresponding database according to the configuration information of each microservice, and send the corresponding database to each microservice; the database includes at least one of a transaction configuration database, a global addressing view database, and a consumption transaction code database, and the consumption transaction code database includes a consumption transaction code list for each microservice.
[0091] Specifically, in response to receiving the configuration information sent by each microservice, a transaction configuration database is configured according to the transaction configuration data in the configuration information sent by each microservice, and is used to store the transaction configuration data of each microservice. The transaction configuration data includes but is not limited to the microservice identifier, multiple transaction codes of the microservice, the functional information of each transaction code, the transaction code address corresponding to each transaction code (such as URI path), and at least one resource environment information in the microservice. For the sake of convenience, the transaction configuration database can also be called a transaction code configuration model, and the global addressing view database can also be called a global addressing view model. The transaction configuration data of a microservice can also be called the metadata of the microservice.
[0092] As an example and not limitation, each microservice may include an integration agent for receiving a database, creating a service instance, registering, sending a microservice call request, and / or receiving a microservice call request.
[0093] Exemplarily, the integration agent of each microservice can generate multiple corresponding service instances based on the received database and register them in the registration component. At the same time, the microservice identifier of each microservice, the transaction code corresponding to the microservice and other information are stored in the registration component to facilitate addressing of the service instance.
[0094] In some embodiments, each of the resource environment information includes an environment identifier, a name of a registration component corresponding to the environment identifier, and a cluster address of the registration component.
[0095] Specifically, each microservice includes multiple resource environments, each of which includes a unique environment identifier, a name of a registered component corresponding to the environment identifier, and a cluster address of the registered component. The registered components correspond to the resource environments one by one.
[0096] It is understandable that when a microservice includes multiple resource environment information, directly addressing the service through the microservice identifier of the microservice may not accurately find the target service in many resource environments, resulting in low efficiency of microservice calls.
[0097] This embodiment provides each resource environment information in the transaction configuration database, and in the global addressing view database, each transaction code corresponds to only one resource environment information. It is possible to quickly match the resource environment that can provide the service instance based on the transaction code, thereby quickly finding the target service instance corresponding to the first transaction code from the cluster environment under the resource environment.
[0098] For example, if the type of the target service carried in the microservice call request is to delete an order, the target service instance that can provide the delete order service can be quickly found directly in the resource environment corresponding to the transaction code of the delete order service instance.
[0099] Specifically, according to the global addressing view data in the configuration information sent by each microservice, a global addressing view database is configured, and the global addressing view database is used to store the global addressing view data of each microservice.
[0100] Specifically, according to the consumption transaction code data in the configuration information sent by each microservice, a consumption transaction code list corresponding to each microservice is configured to obtain a consumption transaction code database. The consumption transaction code database is used to store the consumption transaction code list of each microservice. The transaction configuration database, the global addressing view database, and the consumption transaction code list corresponding to each microservice are sent to each microservice.
[0101] In some embodiments, the publishing environment identifier in the global addressing view data may be updated.
[0102] As an example but not a limitation, when there is an abnormality in the resource environment, the publishing environment identifier in the global addressing view data sent by the microservice can be updated to replace the corresponding registered component name and the cluster address of the registered component. In this way, the cluster environment used by consumers to address service instances can be replaced.
[0103] As an example but not a limitation, when the same resource environment exists between two microservices, the provider microservice can provide in the global addressing view data: the environment identifier of the same resource environment as the service instance involved by the consumer service as the publishing environment identifier. In this way, the consumer service does not need to access across regions, and can directly address the target service instance from the same resource environment, which reduces the addressing time and improves the efficiency of microservice calls.
[0104] In some embodiments, the global addressing view database includes the global addressing view data of each of the microservices, and the global addressing view data of each of the microservices includes at least one transaction code to be served; the consumption transaction code list includes at least one transaction code to be consumed; wherein the transaction code to be served is used to indicate the transaction code for providing the service, and the transaction code to be consumed is used to indicate the transaction code for the service to be called.
[0105] Specifically, the global addressing view data of each microservice includes at least one transaction code to be serviced of the microservice, and the at least one transaction code to be serviced of the microservice includes: a transaction code selected from all transaction codes of the microservice and providing services to other microservices except the microservice.
[0106] Specifically, the consumption transaction code list includes at least one transaction code to be consumed, and the transaction code to be consumed in the consumption transaction code list is: the transaction code of the service to be called by the microservice.
[0107] In some embodiments, the microservice can determine the corresponding transaction code to be called based on the transaction code to be serviced in the global addressing view, so as to quickly implement the operation of addressing the target service instance according to the global addressing view database and avoid calling the wrong microservice.
[0108] Specifically, the transaction codes to be consumed in the consumption transaction code list include: transaction codes of services to be called by the microservice corresponding to the consumption transaction code list, which are selected from the transaction codes to be served of other microservices except the microservice corresponding to the consumption transaction code list.
[0109] Exemplarily, the transaction code of microservice 2 includes transaction code JYM007 for deleting order service, transaction code JYM008 for adding order service, and transaction code JYM009 for modifying order information service, wherein the transaction code to be served includes transaction code JYM007 for providing deleting order service and transaction code JYM008 for providing adding order service. The transaction code of microservice 3 includes transaction code JYM101 for telephone inquiry service and transaction code JYM102 for telephone communication service. Among them, the transaction code to be served includes transaction code JYM102 for providing telephone communication service. The service code to be consumed in microservice 1 includes transaction codes of services to be called selected from the transaction codes to be served of microservice 2, including transaction code JYM007 for calling deleting order service and transaction code JYM008 for calling adding order service, and transaction codes of services to be called selected from the transaction codes to be served of microservice 3, including transaction code JYM102 for calling telephone communication service.
[0110] Specifically, the global addressing view data sent by each microservice includes: multiple transaction codes to be serviced of the microservice, and the global addressing data database constructed based on the global addressing view data of each microservice includes: multiple transaction codes to be serviced of each microservice.
[0111] As an example but not a limitation, the global addressing data database can be sent to each microservice through the data delivery component to implement the global layout operation of the transaction code to be served that provides services in each microservice. In this way, each microservice can obtain the transaction code to be served that is used to provide services in all microservices from the global addressing data database, and in the scenario of calling a microservice, the corresponding microservice call request can be determined.
[0112] In some embodiments, the global addressing view database also includes a microservice identifier of each of the microservices, and a publishing environment identifier corresponding one-to-one to each transaction code to be serviced; the transaction configuration database includes transaction configuration data of each of the microservices, and the transaction configuration data includes the microservice identifier of the microservice, multiple transaction codes of the microservice, and at least one resource environment information of the microservice; each of the resource environment information includes an environment identifier, the name of the registration component corresponding to the environment identifier, and the cluster address of the registration component; the multiple transaction codes of the microservice include each of the transaction codes to be serviced of the microservice.
[0113] Specifically, the global addressing view data of each microservice also includes the microservice identifier of the microservice and a publishing environment identifier corresponding to each transaction code to be served in the microservice. Correspondingly, the global addressing view database also includes the microservice identifier of each microservice and an environment identifier corresponding to each transaction code to be served in each microservice.
[0114] Through the microservice identifiers of each microservice in the global addressing view database, multiple transaction codes to be served in each microservice, and a publishing environment identifier corresponding to each transaction code to be served, the microservice that matches the second microservice identifier carried in the microservice call request and the transaction code to be served that matches the first transaction code can be matched in the global addressing view database, thereby quickly determining the publishing environment identifier corresponding to the first transaction code.
[0115] Specifically, the transaction configuration database includes transaction configuration data of each microservice, and the transaction configuration data provided by each microservice includes the microservice identifier of the microservice, multiple transaction codes in the microservice, and at least one resource environment information in the microservice. The corresponding transaction configuration database includes: the microservice identifier of each microservice, multiple transaction codes of each microservice, and at least one resource environment information of each microservice. In addition, each resource environment information includes but is not limited to an environment identifier, the name of the registration component corresponding to the environment identifier, and the cluster address of the registration component. The multiple transaction codes of each microservice include the transaction codes to be served of the microservice, that is, the transaction codes to be served of the microservice are one or more transaction codes selected from the multiple transaction codes of the microservice.
[0116] In this way, when the publishing environment identifier corresponding to the first transaction code is determined, the environment identifier matching the publishing environment identifier can be found in the transaction configuration database, thereby determining the unique resource environment information corresponding to the first transaction code. And quickly determine the name of the registered component in the resource environment information, and the cluster address of the registered component, so that a cluster address corresponding to the first transaction code can be determined, so as to quickly perform addressing service operations in the cluster address.
[0117] The execution subject of the method of this embodiment may be Figure 2 The server shown in .
[0118] In some embodiments, step S101 includes:
[0119] In response to receiving the configuration information sent by each of the microservices, constructing the transaction configuration database based on the transaction configuration data in the configuration information of each of the microservices;
[0120] Building the global addressing view database based on the global addressing view data in the configuration information of each of the microservices;
[0121] Based on the consumption transaction code data in the configuration information of each microservice, a consumption transaction code list corresponding to each microservice is constructed; wherein the consumption transaction code data includes multiple transaction codes of at least one microservice;
[0122] The transaction configuration database and the global addressing view database are sent to each of the microservices, and a consumption transaction code list corresponding to each of the microservices is sent to each of the microservices respectively.
[0123] Specifically, in response to receiving the configuration information sent by each microservice, the transaction configuration data of each microservice is extracted from the configuration information of each microservice, and a transaction configuration database is constructed according to the transaction configuration data of each microservice. The global addressing view data of each microservice is extracted from the configuration information of each microservice, and a global addressing view database is constructed according to the global addressing view data of each microservice.
[0124] Specifically, the corresponding consumption transaction code data is extracted from the configuration information of each microservice, and based on the consumption transaction code data of each microservice, a consumption transaction code list corresponding to each microservice is constructed. The consumption transaction code data of each microservice includes multiple transaction codes to be called of the microservice. The transaction configuration database and the global addressing view database are sent to each microservice, and the consumption transaction code list corresponding to the microservice is sent to each microservice.
[0125] S102. In response to receiving a microservice call request, determine call information corresponding to the microservice call request; wherein the call information includes a first microservice identifier, a second microservice identifier, and a first transaction code; the first microservice identifier is used to indicate a first microservice, and the second microservice identifier is used to indicate a second microservice.
[0126] Specifically, in response to receiving a microservice call request, the microservice call request is parsed to obtain call information corresponding to the microservice call request, and the call information includes a first microservice identifier, a second microservice identifier, and a first transaction code. Among them, the first microservice identifier is used to indicate the first microservice, and the first microservice is used to indicate the consumer microservice. In other words, the first microservice that sends the microservice call request can be determined according to the first microservice identifier. The second microservice identifier is used to indicate the second microservice, and the second microservice is used to indicate the provider microservice. In other words, the target microservice to be called by the first microservice, that is, the second microservice, can be determined according to the second microservice identifier. The first transaction code identifier is used to indicate the unique identity identifier of the target service to be called by the first microservice.
[0127] In some embodiments, step S102 includes:
[0128] In response to receiving the microservice call request, parsing the microservice call request, obtaining a first microservice carried in the microservice call request, and determining a first microservice corresponding to the first microservice identifier;
[0129] A second microservice identifier and a first transaction code carried in the microservice call request are obtained, and a second microservice corresponding to the second microservice identifier is determined.
[0130] Specifically, in response to receiving a microservice call request, the microservice call request is parsed, and the first microservice identifier carried by the microservice call request is determined, thereby determining the first microservice that sends the microservice call request. At the same time, the second microservice identifier and the first transaction code carried by the microservice call request are determined, and the unique identity of the target service and the second microservice to be called are determined.
[0131] S103: When the first transaction code exists in the global addressing view database and the first transaction code exists in the consumption transaction code list of the first microservice, obtain a target publishing environment identifier corresponding to the first transaction code from the global addressing view database.
[0132] Specifically, if there is a transaction code to be served that matches the first transaction code among multiple transaction codes to be served in the global addressing view database, it is determined that the first transaction code has been globally announced. If there is a transaction code to be called that matches the first transaction code among multiple transaction codes to be called in the consumption transaction code list of the first microservice, it is determined that there is a calling relationship between the first microservice and the service corresponding to the first transaction code. In the global addressing map database, based on the transaction code to be served that matches the first transaction code in the second microservice, the publishing environment identifier corresponding to the first transaction code is obtained.
[0133] S104: Obtain registration component information corresponding to the target publishing environment identifier from the transaction configuration database, and address a target service instance corresponding to the first transaction code in the second microservice based on the registration component information, so as to process the microservice call request through the target service instance.
[0134] Specifically, in each environment resource environment information of the second microservice in the transaction configuration database, an environment identifier matching the release environment identifier is determined, and the name and cluster address of the registration component corresponding to the environment identifier matching the release environment identifier are obtained as the registration component information corresponding to the release environment identifier. Based on the registration component information, a target service instance corresponding to the first transaction code is addressed in multiple service instances of the second microservice, and a microservice call request is sent to the target service instance of the second microservice, so as to process the microservice call request based on the target service instance of the second microservice.
[0135] It should be noted that the registration component corresponds to the resource environment (specifically the environment identifier of the resource environment) one by one. The registration component is used to store multiple service instances registered by one or more microservices in the registration component. Each service of the microservice can be implemented by one or more service instances. The service instance corresponding to each service is different.
[0136] For example, microservice 2 includes three services, and the transaction codes of the above three services are: transaction code JYM007 for the delete order service, transaction code JYM008 for the add order service, and transaction code JYM009 for the modify order information service. The health service instances of microservice 2 include SL001, SL002, SL003, SL005, SL006, SL008, and SL009. Among them, the health service instances SL001, SL002, and SL003 can be used to provide the delete order service, corresponding to the transaction code JYM007; the health service instances SL005 and SL006 are used to provide the add order service, corresponding to the transaction code JYM008; the health service instances SL008 and SL009 are used to provide the modify order information service, corresponding to the transaction code JYM009. Correspondingly, when the first transaction code is JYM009, the health service instances SL008 and SL009 corresponding to the transaction code JYM009 can be searched in all health service instances of microservice 2 in the target registration component.
[0137] S105: Receive the processing result of the target service instance sent by the second microservice, and send it to the first microservice.
[0138] Specifically, a processing result of the target service instance sent by the second microservice is received, and the processing result is sent to the first microservice.
[0139] Figure 4 This is a flowchart of step S103 of the microservice calling method provided in the embodiment of the present application. Figure 4 As shown, the microservice calling method step S103 includes the following steps:
[0140] S1031. Match the first transaction code among multiple transaction codes to be called in the consumption transaction code list of the first microservice.
[0141] Specifically, each of the multiple transaction codes to be called in the consumption transaction code list of the first microservice is matched with the first transaction code.
[0142] S1032: When there is a transaction code to be called that matches the first transaction code in the consumption transaction code list of the first microservice, in the global addressing view database, at least one transaction code to be serviced of the second microservice matches the first transaction code.
[0143] Specifically, when there is a transaction code to be called that matches the first transaction code in the consumption transaction code list of the first microservice, it is determined that there is a calling relationship between the first microservice and the second microservice: the first microservice calls the service corresponding to the first transaction code. Each transaction to be served among the multiple transaction codes to be served in the global addressing view database is matched with the first transaction code.
[0144] S1033. When, in the global addressing view database, there is a transaction code to be serviced that matches the first transaction code in at least one transaction code to be serviced of the second microservice, obtaining a target release identifier corresponding to the first transaction code from the global addressing view database.
[0145] Specifically, when there is a transaction code to be serviced matching the first transaction code in the global addressing view database, it is determined that the first transaction code is globally published. In the global addressing view database, the publishing environment identifier corresponding to the transaction code to be serviced matching the first transaction code is used as the publishing environment identifier corresponding to the first transaction code.
[0146] Figure 5 This is a flowchart of step S1033 of the microservice calling method provided in the embodiment of the present application. Figure 5 As shown, the microservice calling method step S1032 includes the following steps:
[0147] S10321. When, in the global addressing view database, there is a transaction code to be served that matches the first transaction code in at least one transaction code to be served of the second microservice, determining the transaction code to be served that matches the first transaction code as the target transaction code to be served.
[0148] Specifically, when there is a transaction code to be serviced that matches the first transaction code in the global addressing view database, the transaction code to be serviced that matches the first transaction code is determined to be the target transaction code to be serviced.
[0149] S10322. Obtain, from the global addressing view database, a publishing environment identifier corresponding to the target transaction code to be serviced as a target publishing identifier corresponding to the first transaction code.
[0150] Specifically, the publishing environment identifier corresponding to the target transaction code to be serviced is searched in the global addressing view database, and the publishing environment identifier corresponding to the target transaction code to be serviced is used as the publishing environment identifier corresponding to the first transaction code.
[0151] It is understandable that the above embodiment is described by first searching for a transaction code to be called that matches the first transaction code in the consumption transaction code list of the first microservice, and then searching for a transaction code to be served that matches the first transaction code in the global addressing view database. In actual applications, the order of the above two steps is not unique and unchanging. Exemplarily, the transaction code to be served that matches the first transaction code may be searched in the global addressing view database first, and then the transaction code to be called that matches the first transaction code may be searched in the consumption transaction code list of the first microservice. Alternatively, the transaction code to be served that matches the first transaction code may be searched in the global addressing view database and the transaction code to be called that matches the first transaction code may be searched in the consumption transaction code list of the first microservice at the same time.
[0152] Figure 6 An exemplary application scenario diagram of a microservice calling method applicable to an embodiment of the present application is provided.
[0153] Figure 6 In the consumption transaction code database, consumption transaction code list 1 of microservice 1 and consumption transaction code list 2 of microservice 2 are stored. Among them, consumption transaction code list 1 stores multiple transaction codes to be called that have a calling relationship with microservice 1, namely, transaction code 1 to be called and transaction code 2 to be called. Consumption transaction code list 2 stores multiple transaction codes to be called that have a calling relationship with microservice 2, namely, transaction code 3 to be called and transaction code 4 to be called. The global addressing view database stores the global addressing view data of microservice 1, which includes the microservice identifier 1 of microservice 1, the transaction code 3 to be served in microservice 1, and the unique publishing environment identifier 5. The global addressing view database also stores the global addressing view data of microservice 2, which includes the microservice identifier 2 of microservice 2, the transaction code 1 to be served in microservice 2, and the unique publishing environment identifier 1.
[0154] The transaction configuration database stores the transaction codes of multiple services in microservice 1 and the transaction code address of each transaction code ( Figure 6 Only two services are shown, namely service X and service Q, and the corresponding transaction codes only show transaction code 3, transaction code address 3, transaction code 4 and transaction code address 5). Multiple resource environments for each service ( Figure 6 Only three resource environment information in microservice 1 are shown, namely resource environment information 4, resource environment information 5, and resource environment information 6). Among them, each service instance of the service corresponding to transaction code 1 is registered in resource environment 1, each service instance of the service corresponding to transaction code 2 is registered in resource environment 3, each service instance of the service corresponding to transaction code 3 is registered in resource environment 4, and each service instance of the service corresponding to transaction code 4 is registered in resource environment 5.
[0155] The transaction configuration database also stores the transaction codes of multiple services in microservice 2 and the transaction code address of each transaction code ( Figure 6 Only two services are shown, namely service Z and service Y, and the corresponding transaction codes only show transaction code 1, transaction code address 1, transaction code 2 and transaction code address 2). Multiple resource environments for each service ( Figure 6 Only three resource environment information in microservice 2 are shown, namely resource environment information 1, resource environment information 2, and resource environment information 3). Each resource environment information includes the environment identifier of the resource environment information, the registered component name, and the cluster address of the registered component.
[0156] The first microservice identifier included in the microservice call request is microservice identifier 1, the second microservice identifier is microservice identifier 2, and the first transaction code is transaction code 1. Correspondingly, it can be determined that microservice 1 calls the service corresponding to transaction code 2 in microservice 2 through the microservice call request.
[0157] In the consumption transaction code list 1 of microservice 1, when the transaction code to be called 1 matches the first transaction code (and transaction code 1), and the transaction code to be served 1 in microservice 2 in the global addressing view database matches the first transaction code, according to the publishing environment identifier 1 corresponding to the transaction code to be served 1 in the global addressing view database, the environment identifier 1 associated with the transaction code 1 is matched in microservice 2. Based on this, multiple healthy service instances ( Figure 6 Only four health service instances of service 2 are shown, represented by hollow dots. Figure 6 (indicated by dotted hollow circles).
[0158] Figure 7 The second flowchart of the microservice calling method provided in the embodiment of the present application. Figure 7 As shown, after step S102, the microservice calling method further includes the following steps:
[0159] S201: Generate call failure information when there is no transaction code to be served matching the first transaction code in the global addressing view database and / or there is no transaction code to be called matching the first transaction code in the consumption transaction code list of the first microservice;
[0160] Specifically, when there is no transaction code to be serviced that matches the first transaction code in the global addressing view database, and when any one or more of the following conditions are met: there is no transaction code to be called that matches the first transaction code in the consumption transaction code list of the first microservice, it is determined that the first transaction code has not been globally announced, and there is no "calling relationship between the first microservice calling the service corresponding to the first transaction code" between the first microservice and the second microservice.
[0161] S202. Send the call failure information to the first microservice; the call failure information is used to prompt the first microservice that the microservice call request has not been successfully called.
[0162] Specifically, in the above case, the first microservice cannot call the first transaction code related service of the second microservice. A call failure message is generated and sent to the first microservice. The call failure message is used to prompt the first microservice that the microservice call request sent by the first microservice to call the first transaction code related service of the second microservice is unsuccessful.
[0163] Figure 8 This is a flowchart of step S104 of the microservice calling method provided in the embodiment of the present application. Figure 8 As shown, the microservice calling method step S104 also includes the following steps:
[0164] S1041. In the transaction configuration database, search for an environment identifier that matches the target publishing environment identifier as the target environment identifier;
[0165] S1042. Determine, in the transaction configuration database, a name and a cluster address of a registration component corresponding to the target environment identifier as registration component information corresponding to the target publishing environment identifier, wherein the registration component information includes the name and the cluster address of the registration component;
[0166] Specifically, based on the second microservice identifier, the environment identifier matching the target publishing environment is searched in the second microservice of the transaction configuration database. And in the transaction configuration database, the registration component name and cluster address corresponding to the environment identifier matching the target publishing environment identifier are searched as the name and cluster address of the registration component corresponding to the target publishing environment identifier. For ease of explanation, the cluster address of the registration component corresponding to the target publishing environment identifier may also be referred to as registration component information.
[0167] Exemplarily, the registration component may be nacos.
[0168] S1043. Determine a registration component corresponding to the name and cluster address of the registration component as a target registration address. In the target address, determine each service instance corresponding to the second microservice based on the second microservice identifier; wherein the target address stores multiple service instances registered by each of the microservices.
[0169] S1044. Determine at least one healthy service instance corresponding to the first transaction code from each service instance of the second microservice in the target registration component, and send a microservice call request to each of the healthy service instances; the healthy service instance is used to indicate a service instance that has the ability to process the call request.
[0170] Specifically, the corresponding registration component is determined according to the name of the registration component and the cluster address as the target registration address. The target registration address stores multiple service instances registered by each microservice. Therefore, each service instance corresponding to the second microservice can be determined based on the second microservice identifier.
[0171] Specifically, at least one healthy service instance corresponding to the first transaction code is found from the multiple service instances registered by the second microservice and stored in the registration component, and a microservice call request is sent to each healthy service instance. A healthy service instance is used to indicate a service instance capable of processing a call request.
[0172] As an example but not a limitation, each microservice can monitor the status of each service instance. When it is detected that one or more service instances do not have the ability to process call requests and it is determined that the service instances that do not have the ability to process call requests are in an unhealthy state, the microservice can deregister the service instances in an unhealthy state. A transaction code deregistration request is sent to the transaction configuration database and the global addressing view database. The server can deregister the transaction code corresponding to the service instance based on the transaction code deregistration request. In this way, it can be avoided that the microservice call result is a call to an unhealthy service instance.
[0173] As a strength rather than a limitation, in microservices, multiple services work in round-robin. At the same time, some services are working and some are idle. The server may not know the running status of each service instance, so it is necessary to send a microservice call request to each healthy service instance.
[0174] S1045. In response to receiving feedback information from the healthy service instance, determine that the healthy service instance corresponding to the feedback information is a target service instance, and send a processing instruction to the target service instance, wherein the processing instruction is used to control the target service instance to process the microservice call request; wherein the feedback information is used to indicate that the service instance is in an idle state.
[0175] Specifically, in response to receiving feedback information from a healthy service instance, when the feedback information indicates that the service instance is in an idle state, determining that the service instance has the ability and time to process a microservice call request, determining that the service instance is a target service instance, and sending a processing instruction to the target service instance to control the target service instance to process the microservice call request.
[0176] It is understandable that in a microservice, when multiple services are polling, there are multiple service instances in an idle state at the same time. The multiple service instances in an idle state receive instructions or requests in sequence according to the polling order. Based on this, the first service instance that receives the microservice call request will directly feedback information, so the target service instance can be directly determined based on the feedback information.
[0177] Fig. 9 This is a schematic diagram of the structure of the microservice calling device provided in the embodiment of the present application. Fig. 9 As shown, the microservice calling device includes:
[0178] The database configuration module 901 is used to configure the corresponding database according to the configuration information of each microservice in response to receiving the configuration information sent by each microservice, and send the corresponding database to each microservice; the database includes at least one of a transaction configuration database, a global addressing view database and a consumption transaction code database, and the consumption transaction code database includes a consumption transaction code list of each microservice;
[0179] The call information determination module 902 is used to determine the call information corresponding to the microservice call request in response to receiving the microservice call request; wherein the call information includes a first microservice identifier, a second microservice identifier, and a first transaction code; the first microservice identifier is used to indicate the first microservice, and the second microservice identifier is used to indicate the second microservice;
[0180] The environment identifier acquisition module 903 is used to acquire the target publishing environment identifier corresponding to the first transaction code from the global addressing view database when the first transaction code exists in the global addressing view database and the first transaction code exists in the consumption transaction code list of the first microservice;
[0181] The request processing module 904 is used to obtain the registration component information corresponding to the target publishing environment identifier from the transaction configuration database, and address the target service instance corresponding to the first transaction code in the second microservice based on the registration component information, so as to process the microservice call request through the target service instance;
[0182] The sending module 905 is used to receive the processing result of the target service instance sent by the second microservice, and send it to the first microservice.
[0183] In some embodiments, the global addressing view database includes global addressing view data of each of the microservices, and the global addressing view data of each of the microservices includes at least one transaction code to be served; the consumption transaction code list includes at least one transaction code to be consumed; wherein the transaction code to be served is used to indicate a transaction code for providing a service, and the transaction code to be consumed is used to indicate a transaction code for a service to be called;
[0184] The environment identification acquisition module includes:
[0185] A first matching unit, configured to match the first transaction code among a plurality of transaction codes to be called in a consumption transaction code list of the first microservice;
[0186] a second matching unit, configured to match the first transaction code in at least one transaction code to be served of the second microservice in the global addressing view database when there is a transaction code to be called that matches the first transaction code in the consumption transaction code list of the first microservice;
[0187] A first acquisition unit is configured to acquire a target release identifier corresponding to the first transaction code from the global addressing view database when, in the global addressing view database, there is a transaction code to be serviced that matches the first transaction code in at least one transaction code to be serviced of the second microservice.
[0188] In some embodiments, the global addressing view database further includes a microservice identifier of each microservice and a publishing environment identifier corresponding to each transaction code to be serviced; the transaction configuration database includes transaction configuration data of each microservice, the transaction configuration data includes the microservice identifier of the microservice, multiple transaction codes of the microservice, and at least one resource environment information of the microservice; each resource environment information includes an environment identifier, a name of a registration component corresponding to the environment identifier, and a cluster address of the registration component; the multiple transaction codes of the microservice include each of the transaction codes to be serviced of the microservice;
[0189] The first acquisition unit includes:
[0190] A first determining subunit is configured to, when there is a to-be-served transaction code matching the first transaction code in at least one to-be-served transaction code of the second microservice in the global addressing view database, determine the to-be-served transaction code matching the first transaction code as a target to-be-served transaction code;
[0191] The first acquisition subunit is used to acquire, from the global addressing view database, a publishing environment identifier corresponding to the target transaction code to be serviced as a target publishing identifier corresponding to the first transaction code.
[0192] In some embodiments, the transaction configuration database includes at least one resource environment information of each of the microservices, each of the resource environment information includes an environment identifier, a name of a registration component corresponding to the environment identifier, and a cluster address of the registration component;
[0193] Request processing module, including:
[0194] An environment identifier acquisition unit is used to search the transaction configuration database for an environment identifier that matches the target release environment identifier as the target environment identifier;
[0195] A component information acquisition unit, used to determine, in the transaction configuration database, a name and a cluster address of a registered component corresponding to a target environment identifier as registered component information corresponding to the target publishing environment identifier, wherein the registered component information includes the name and the cluster address of the registered component;
[0196] A microservice determination unit, configured to determine a registration component corresponding to the name and cluster address of the registration component as a target registration address, and in the target address, determine each service instance corresponding to the second microservice based on the second microservice identifier; wherein the target address stores multiple service instances registered by each of the microservices;
[0197] a sending unit, configured to determine at least one healthy service instance corresponding to the first transaction code from each service instance of the second microservice in the target registration component, and send a microservice call request to each of the healthy service instances; the healthy service instance is used to indicate a service instance capable of processing the call request;
[0198] A control unit, for, in response to receiving feedback information from the health service instance, determining that the health service instance corresponding to the feedback information is a target service instance, and sending a processing instruction to the target service instance, wherein the processing instruction is used to control the target service instance to process the microservice call request; wherein the feedback information is used to indicate that the service instance is in an idle state.
[0199] In some embodiments, the microservice calling device further includes:
[0200] a generating module, configured to generate call failure information when there is no transaction code to be served matching the first transaction code in the global addressing view database and / or there is no transaction code to be called matching the first transaction code in the consumption transaction code list of the first microservice;
[0201] The prompt module is used to send the call failure information to the first microservice; the call failure information is used to prompt the first microservice that the microservice call request has not been successfully called.
[0202] In some embodiments, the configuration information includes at least one of transaction configuration data, global addressing view data, and consumption transaction code data;
[0203] Database configuration module, including:
[0204] A first construction unit, configured to construct the transaction configuration database based on transaction configuration data in the configuration information of each microservice in response to receiving the configuration information sent by each microservice;
[0205] A second construction unit is used to construct the global addressing view database based on the global addressing view data in the configuration information of each of the microservices;
[0206] A third construction unit is used to construct a consumption transaction code list corresponding to each of the microservices based on the consumption transaction code data in the configuration information of each of the microservices; wherein the consumption transaction code data includes multiple transaction codes of at least one microservice;
[0207] The second sending unit is used to send the transaction configuration database and the global addressing view database to each of the microservices, and to send a consumption transaction code list corresponding to each of the microservices to each of the microservices.
[0208] In some embodiments, calling the information determination module includes:
[0209] A parsing unit, configured to, in response to receiving the microservice call request, parse the microservice call request, obtain a first microservice carried in the microservice call request, and determine a first microservice corresponding to the first microservice identifier;
[0210] The microservice determination unit is used to obtain the second microservice identifier and the first transaction code carried in the microservice call request, and determine the second microservice corresponding to the second microservice identifier.
[0211] The microservice calling device provided in the embodiment of the present application can be used to execute the technical solution of the microservice calling method in the above embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0212] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. For example, the request processing module 904 can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the request processing module 904. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0213] Fig.10 This is a schematic diagram of the structure of the server provided in the embodiment of the present application. Fig.10 As shown, the server may include: a transceiver 101 , a processor 102 , and a memory 103 .
[0214] The processor 102 executes the computer execution instructions stored in the memory, so that the processor 102 executes the scheme in the above embodiment. The processor 102 can be a general-purpose processor, including a central processing unit CPU, a network processor (network processor, NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0215] The memory 103 is connected to the processor 102 via a system bus and implements communication therebetween. The memory 103 is used to store computer program instructions.
[0216] The transceiver 101 may be used to obtain tasks to be executed and configuration information of the tasks to be executed.
[0217] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to realize the communication between the database access device and other computers (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory.
[0218] An embodiment of the present application also provides a chip for running instructions, which is used to execute the technical solution of the microservice calling method in the above embodiment.
[0219] The embodiment of the present application also provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a computer, the computer executes the technical solution of the microservice calling method of the above embodiment.
[0220] An embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When at least one processor executes the computer program, the technical solution of the microservice calling method in the above embodiment can be implemented.
[0221] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0222] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.
[0223] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0224] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.
[0225] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0226] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0227] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0228] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0229] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic control unit or a main control device.
[0230] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0231] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A microservice calling method, characterized in that: include: In response to receiving the configuration information sent by each microservice, a corresponding database is configured according to the configuration information of each microservice, and the corresponding database is sent to each microservice; the database includes at least one of a transaction configuration database, a global addressing view database, and a consumption transaction code database, and the consumption transaction code database includes a consumption transaction code list of each microservice; In response to receiving a microservice call request, determining call information corresponding to the microservice call request; wherein the call information includes a first microservice identifier, a second microservice identifier, and a first transaction code; the first microservice identifier is used to indicate a first microservice, and the second microservice identifier is used to indicate a second microservice; If the first transaction code exists in the global addressing view database and the first transaction code exists in the consumption transaction code list of the first microservice, obtaining a target publishing environment identifier corresponding to the first transaction code from the global addressing view database; Acquire registration component information corresponding to the target publishing environment identifier from the transaction configuration database, and address a target service instance corresponding to the first transaction code in the second microservice based on the registration component information, so as to process the microservice call request through the target service instance; Receive the processing result of the target service instance sent by the second microservice, and send it to the first microservice.
2. The method according to claim 1, characterized in that The global addressing view database includes the global addressing view data of each of the microservices, and the global addressing view data of each of the microservices includes at least one transaction code to be served; the consumption transaction code list includes at least one transaction code to be consumed; wherein the transaction code to be served is used to indicate the transaction code for providing the service, and the transaction code to be consumed is used to indicate the transaction code for the service to be called; When the first transaction code exists in the global addressing view database and the first transaction code exists in the consumption transaction code list of the first microservice, acquiring the target publishing environment identifier corresponding to the first transaction code from the global addressing view database includes: Match the first transaction code among multiple transaction codes to be called in the consumption transaction code list of the first microservice; When there is a transaction code to be called that matches the first transaction code in the consumption transaction code list of the first microservice, the first transaction code is matched in at least one transaction code to be served of the second microservice in the global addressing view database; In the global addressing view database, when there is a transaction code to be serviced that matches the first transaction code in at least one transaction code to be serviced of the second microservice, a target release identifier corresponding to the first transaction code is obtained from the global addressing view database.
3. The method according to claim 1 or 2, characterized in that: The global addressing view database also includes a microservice identifier of each microservice and a publishing environment identifier corresponding to each transaction code to be served; the transaction configuration database includes transaction configuration data of each microservice, and the transaction configuration data includes the microservice identifier of the microservice, multiple transaction codes of the microservice, and at least one resource environment information of the microservice; each resource environment information includes an environment identifier, a name of a registration component corresponding to the environment identifier, and a cluster address of the registration component; the multiple transaction codes of the microservice include each transaction code to be served of the microservice; When, in the global addressing view database, there is a transaction code to be serviced that matches the first transaction code in at least one transaction code to be serviced of the second microservice, acquiring a target release identifier corresponding to the first transaction code from the global addressing view database includes: In the global addressing view database, when there is a transaction code to be served matching the first transaction code in at least one transaction code to be served of the second microservice, determining the transaction code to be served matching the first transaction code as the target transaction code to be served; A publishing environment identifier corresponding to the target transaction code to be serviced is obtained from the global addressing view database as a target publishing identifier corresponding to the first transaction code.
4. The method according to any one of claims 1 to 3, characterized in that The transaction configuration database includes at least one resource environment information of each microservice, each of which includes an environment identifier, a name of a registered component corresponding to the environment identifier, and a cluster address of the registered component; The step of acquiring registration component information corresponding to the target publishing environment identifier from the transaction configuration database, and addressing a target service instance corresponding to the first transaction code in the second microservice based on the registration component information to process the microservice call request through the target service instance includes: In the transaction configuration database, searching for an environment identifier that matches the target publishing environment identifier as the target environment identifier; In the transaction configuration database, determining the name and cluster address of the registration component corresponding to the target environment identifier as the registration component information corresponding to the target publishing environment identifier, wherein the registration component information includes the name and cluster address of the registration component; Determine the registration component corresponding to the name and cluster address of the registration component as the target registration address, and in the target address, determine each service instance corresponding to the second microservice based on the second microservice identifier; wherein the target address stores multiple service instances registered by each of the microservices; Determine at least one healthy service instance corresponding to the first transaction code from each service instance of the second microservice in the target registration component, and send a microservice call request to each of the healthy service instances; the healthy service instance is used to indicate a service instance capable of processing the call request; In response to receiving feedback information from the healthy service instance, determining that the healthy service instance corresponding to the feedback information is a target service instance, and sending a processing instruction to the target service instance, wherein the processing instruction is used to control the target service instance to process the microservice call request; wherein the feedback information is used to indicate that the service instance is in an idle state.
5. The method according to claim 1 or 2, characterized in that: After the response to receiving the microservice call request and determining the call information corresponding to the microservice call request, the method further includes: When there is no transaction code to be served matching the first transaction code in the global addressing view database, and / or there is no transaction code to be called matching the first transaction code in the consumption transaction code list of the first microservice, a call failure message is generated; The call failure information is sent to the first microservice; the call failure information is used to prompt the first microservice that the microservice call request has not been successfully called.
6. The method according to any one of claims 1 to 5, characterized in that The configuration information includes at least one of transaction configuration data, global addressing view data, and consumption transaction code data; Correspondingly, in response to receiving the configuration information sent by each microservice, configuring the corresponding database according to the configuration information of each microservice, and sending the corresponding database to each microservice, includes: In response to receiving the configuration information sent by each of the microservices, constructing the transaction configuration database based on the transaction configuration data in the configuration information of each of the microservices; Building the global addressing view database based on the global addressing view data in the configuration information of each of the microservices; Based on the consumption transaction code data in the configuration information of each microservice, a consumption transaction code list corresponding to each microservice is constructed; wherein the consumption transaction code data includes multiple transaction codes of at least one microservice; The transaction configuration database and the global addressing view database are sent to each of the microservices, and a consumption transaction code list corresponding to each of the microservices is sent to each of the microservices respectively.
7. The method according to any one of claims 1 to 6, characterized in that The step of determining, in response to receiving a microservice call request, call information corresponding to the microservice call request includes: In response to receiving the microservice call request, parsing the microservice call request, obtaining a first microservice carried in the microservice call request, and determining a first microservice corresponding to the first microservice identifier; A second microservice identifier and a first transaction code carried in the microservice call request are obtained, and a second microservice corresponding to the second microservice identifier is determined.
8. A microservice calling device, characterized in that: include: A database configuration module, configured to, in response to receiving configuration information sent by each microservice, configure a corresponding database according to the configuration information of each microservice, and send the corresponding database to each microservice; the database includes at least one of a transaction configuration database, a global addressing view database, and a consumption transaction code database, and the consumption transaction code database includes a consumption transaction code list of each microservice; A call information determination module, configured to determine, in response to receiving a microservice call request, call information corresponding to the microservice call request; wherein the call information includes a first microservice identifier, a second microservice identifier, and a first transaction code; the first microservice identifier is used to indicate a first microservice, and the second microservice identifier is used to indicate a second microservice; an environment identifier acquisition module, configured to acquire a target publishing environment identifier corresponding to the first transaction code from the global addressing view database if the first transaction code exists in the global addressing view database and the first transaction code exists in the consumption transaction code list of the first microservice; a request processing module, configured to obtain registration component information corresponding to the target publishing environment identifier from the transaction configuration database, and address a target service instance corresponding to the first transaction code in the second microservice based on the registration component information, so as to process the microservice call request through the target service instance; A sending module is used to receive the processing result of the target service instance sent by the second microservice, and send it to the first microservice.
9. A server, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
11. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 7 when being executed by a processor.
Citation Information
Patent Citations
Methods and systems for identity creation, verification and management
CN108292331A
Heterogeneous system data calling method and device, equipment and storage medium
CN111381985A
Load balancing method and device based on micro-service, equipment and storage medium
CN111464592A
Government affair service access control method and device
CN112685201A
Chaotic engineering fault drilling scene generation method and device, equipment and storage medium
CN115828103A
