Method, device and computer readable medium for invoking a business service
By constructing and parsing a service composition model, the execution order and state of microservices are controlled, solving the problem of uncertain execution order in microservice composition and achieving stable and efficient invocation of business services.
Patent Information
- Application Number
- CN202410709744.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2025-12-26
- Estimated Expiration
- 2044-06-03
AI Technical Summary
In existing technologies, the microservice composition approach cannot guarantee the execution order, which can easily lead to business logic errors, resulting in service call failures or performance degradation.
Construct a service composition model for business services, including multiple microservices, business relationships between microservices, and call states, and store it in the configuration center; respond to execution requests, parse the service composition model to generate service list data, call microservices in sequence, and adjust the execution state to process business services.
By controlling the execution order and state of microservices, business logic errors can be reduced, service call failures or performance degradation can be avoided, and call efficiency can be improved.
Smart Images

Figure CN118449989B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of big data, and in particular to a method and device for calling a business service, and a computer readable medium. BACKGROUND
[0002] With the increase of users over time, the access volume increases, and the pressure on the server gradually tends to saturation. In order to avoid the sudden increase in access volume and cause unbearable pressure on the service, resulting in the overall service downtime, the java microservice can be split, and the decoupling can be realized through the microservice.
[0003] In the process of implementing the present application, the present application found that at least the following problems exist in the prior art: The microservice combination method mostly adopts parallel processing, and since the execution order of the microservice cannot be guaranteed, business logic errors are prone to occur, resulting in service call failure or performance degradation. SUMMARY
[0004] Therefore, the embodiments of the present application provide a method and device for calling a business service, and a computer readable medium, which can reduce business logic errors and avoid service call failure or performance degradation.
[0005] To achieve the above object, according to one aspect of the embodiments of the present application, a method for calling a business service is provided, comprising:
[0006] A service combination model of the business service is constructed based on a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and the service combination model is stored in a configuration center;
[0007] In response to an execution request of the business service, after the execution request of the business service is authenticated, the service combination model is obtained from the configuration center based on a business identifier of the business service, and the service combination model is parsed in combination with the execution request of the business service to generate service list data of the business service;
[0008] According to the service list data of the business service, the execution order of the microservices is known, and the microservices are called in sequence according to the execution order of the microservices, and the execution state of the microservices is adjusted to process the execution request of the business service.
[0009] The service combination model of the business service is constructed based on a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and the service combination model is stored in a configuration center, comprising:
[0010] According to the business logic of the business service, the plurality of microservices involved in the business service are filtered, and the calling state of the plurality of microservices is determined.
[0011] determine a calling order of the microservices based on a business logic order in the business relationship among the plurality of microservices, and determine a dependency relationship and a dependency condition among the microservices according to a data flow of the microservices in the business relationship among the plurality of microservices;
[0012] establish the service combination model according to the calling order of the microservices, the dependency relationship and the dependency condition among the microservices, a calling state of the plurality of microservices, an input parameter of the microservices and an output parameter of the microservices, and store the service combination model into the configuration center based on the business identifier of the business service.
[0013] In response to the execution request of the business service, after the execution request of the business service is authenticated, the service combination model is obtained from the configuration center based on the business identifier of the business service, and the service combination model is parsed in combination with the execution request of the business service to generate service list data of the business service, including:
[0014] In response to the execution request of the business service, after the execution request of the business service is authenticated, the service combination model is obtained from the configuration center based on the business identifier of the business service, and the service combination model is parsed to obtain the microservices of the business service, the calling order of the microservices, the calling state of the microservices, the dependency relationship of the microservices and the dependency condition of the microservices.
[0015] According to the execution request of the business service, the dependency relationship of the microservices, the dependency condition of the microservices and the calling state of the microservices, the execution microservices of the business service are screened out.
[0016] According to the calling order of the execution microservices, the service list data of the business service is constructed.
[0017] According to the calling order of the execution microservices, the service list data of the business service is constructed, including:
[0018] According to the execution request of the business service, the execution microservices are divided into a plurality of business execution groups.
[0019] According to the execution microservices in the business execution group and the calling order of the execution microservices, the service list data of the business execution group is constructed.
[0020] According to the calling order of the microservices and the service list data of the business execution group, the service list data of the business service is established.
[0021] The service list data according to the business service is used to learn the execution sequence of the microservices and sequentially call the microservices according to the execution sequence of the microservices, and the execution state of the microservices is adjusted to process the execution request of the business service, including:
[0022] Based on the service list data of the business service, the execution sequence of the microservices and the dependency condition of the microservices are obtained, and the execution state of the microservices is adjusted according to the dependency condition of the microservices;
[0023] According to the execution sequence of the microservices and the execution state of the microservices, the microservices are called to process the execution request of the business service.
[0024] According to the execution sequence of the microservices and the execution state of the microservices, the microservices are called to process the execution request of the business service, including:
[0025] If the execution state of the microservices includes blocking or failure, the configuration center is queried based on the blocked or failed microservices and the execution request to obtain an exception handling operation;
[0026] According to the exception handling operation, the blocked or failed microservices are called again to continue processing the execution request of the business service.
[0027] The method further includes:
[0028] The service combination model of the business service is updated according to the business relationship between the adjusted microservices of the business service and the adjusted microservices, and the service combination model of the business service of the configuration center is replaced by the updated service combination model of the business service.
[0029] According to a second aspect of the embodiment of the application, a device for calling a business service is provided, including:
[0030] The construction module is configured to construct a service combination model of the business service by using a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and store the service combination model to a configuration center;
[0031] The analysis module is configured to, in response to an execution request of the business service, after the execution request of the business service is authenticated, obtain the service combination model from the configuration center based on a business identifier of the business service, and analyze the service combination model to generate service list data of the business service in combination with the execution request of the business service.
[0032] The execution module is configured to obtain the execution sequence of the microservices according to the service list data of the business service, and sequentially call the microservices according to the execution sequence of the microservices, and adjust the execution state of the microservices to process the execution request of the business service.
[0033] According to a third aspect of the embodiments of the present application, an electronic device for calling a business service is provided, comprising:
[0034] one or more processors;
[0035] a storage device configured to store one or more programs,
[0036] When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.
[0037] According to a fourth aspect of the embodiments of the present application, a computer readable medium having a computer program stored thereon is provided, the program being executed by a processor to implement the method as described above.
[0038] According to a fifth aspect of the embodiments of the present application, a computer program product is provided, comprising a computer program, the program being executed by a processor to implement the method as described above.
[0039] One embodiment of the above application has the following advantages or beneficial effects: a service combination model of a business service is constructed based on a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and the service combination model is stored in a configuration center; in response to an execution request of the business service, after the execution request of the business service is authenticated, the service combination model is obtained from the configuration center based on a business identifier of the business service, and the service combination model is parsed in combination with the execution request of the business service to generate service list data of the business service; according to the service list data of the business service, the execution sequence of the microservices is obtained, and the microservices are sequentially called according to the execution sequence of the microservices, and the execution state of the microservices is adjusted to process the execution request of the business service. The execution request of the business service is processed by calling the microservices according to the service combination model, the sequence and execution state of the microservices are controllable, thereby reducing business logic errors and avoiding service calling failure or performance degradation.
[0040] The further effects of the above-mentioned non-conventional optional mode will be described in the following with reference to the specific embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0041] The accompanying drawings are used to better understand the present application and do not constitute an improper limitation on the present application. Among them:
[0042] Figure 1is a main flowchart diagram of a method for invoking a business service according to an embodiment of the present application;
[0043] Figure 2 is a flowchart diagram of constructing a service combination model of a business service and storing the service combination model to a configuration center according to an embodiment of the present application;
[0044] Figure 3 is a schematic diagram of invoking microservices for purchasing goods according to an embodiment of the present application;
[0045] Figure 4 is a schematic diagram of dependency relationship between microservices according to an embodiment of the present application;
[0046] Figure 5 is a flowchart diagram of generating a service list data of a business service by parsing a service combination model in combination with an execution request of the business service according to an embodiment of the present application;
[0047] Figure 6 is a flowchart diagram of constructing a service list data of a business service by executing microservices according to an embodiment of the present application;
[0048] Figure 7 is a flowchart diagram of adjusting an execution state of a microservice to process an execution request of a business service according to an embodiment of the present application;
[0049] Figure 8 is a flowchart diagram of re-invoking a blocked or failed microservice according to an embodiment of the present application;
[0050] Figure 9 is a main structure diagram of an apparatus for invoking a business service according to an embodiment of the present application;
[0051] Figure 10 is an exemplary system architecture diagram to which embodiments of the present application can be applied;
[0052] Figure 11 is a structure diagram of a computer system of a terminal device or a server suitable for implementing embodiments of the present application. DETAILED DESCRIPTION
[0053] Exemplary embodiments of the present application are described below with reference to the accompanying drawings, which include various details of the embodiments in order to assist in understanding them. These should be considered as merely exemplary, and therefore, it will be recognized by those of ordinary skill that various modifications and changes in the embodiments described herein can be made without departing from the scope and spirit of the application. Also, for the sake of brevity and clarity, descriptions of well-known functions and constructions are omitted herein. The acquisition, storage, use, processing, etc. of data in the technical solutions of the present application comply with relevant provisions of national laws and regulations.
[0054] In order to solve the problem that the execution order of the service cannot be guaranteed, and the business logic error is prone to occur, the technical solution in the embodiment of the application can be used.
[0055] Referring to Figure 1 , Figure 1 is a main flow diagram of a method for calling a business service according to an embodiment of the application, and a microservice is called through a service combination model to process an execution request. Figure 1 Specifically, the method includes the following steps.
[0056] S101, a service combination model of a business service is constructed based on a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and the service combination model is stored in a configuration center.
[0057] The microservice is a software development technology, and is a variant of a service-oriented architecture (SOA) architecture style, which constructs an application as a collection of loosely coupled services. The microservice refers to developing a single small but business function service, and each service has its own processing and lightweight communication mechanism, and can be deployed on a single or multiple servers.
[0058] In the embodiment of the application, the business service is executed through a plurality of microservices. As an example, the business service includes purchasing a commodity or refunding a commodity. It can be understood that a plurality of microservices are called to implement the business service. The plurality of microservices have a business relationship. For example, the business service includes purchasing a commodity, and involves a shopping cart microservice and a commodity microservice. The relationship between the shopping cart microservice and the commodity microservice is the business relationship.
[0059] Further, a service combination model of a business service is constructed based on a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and the service combination model is stored in a configuration center. The calling state of the microservice is the state of a microservice component that executes the microservice. As an example, the calling state of the microservice includes callable and prohibited calling. In the case that the calling state of the microservice is callable, the microservice component is used to implement the execution of the microservice. In the case that the calling state of the microservice is prohibited calling, it indicates that the microservice component is unavailable, and therefore the microservice cannot be executed.
[0060] Each microservice represents a specific java microservice. In an embodiment of the application, the configuration center includes a zookeeper.
[0061] Referring to Figure 2 that is 200, Figure 2 is a flow diagram of constructing a service combination model of a business service and storing the service combination model in a configuration center according to an embodiment of the application. Specifically, the method includes the following steps.
[0062] S201, screening a plurality of microservices involved in the business service according to the business logic of the business service.
[0063] Each microservice is an independent node responsible for processing a specific business function or data. The execution of the business service involves multiple microservices. The plurality of microservices involved in the business service can be screened according to the business logic of the business service.
[0064] As an example, the business service includes purchasing goods, and the plurality of microservices involved in the business service is screened according to the business logic of the business service: user microservice, shopping cart microservice, goods microservice, order microservice, and payment microservice.
[0065] S202, determining the calling order of the microservices based on the business logic order in the business relationship between the plurality of microservices, and determining the dependency relationship and dependency condition between the microservices according to the data flow of the microservices in the business relationship between the plurality of microservices.
[0066] The business relationship of the business service includes the business logic order and the data flow of the microservices. The business logic order is the execution order of the microservices. The data flow of the microservices is the data sequence from one microservice to another microservice in the data processing process.
[0067] In an embodiment of the present application, the calling order of the microservices is determined based on the business logic order in the business relationship between the plurality of microservices. As an example, the business logic order in the business relationship between the plurality of microservices includes: order microservice and payment microservice. The calling order of the microservices is determined to include: executing the order microservice first, and then executing the payment microservice.
[0068] In an embodiment of the present application, the dependency relationship and dependency condition between the microservices are determined according to the data flow of the microservices in the business relationship between the plurality of microservices. As an example, the user microservice and the order microservice have a dependency relationship and a dependency condition; the goods microservice and the order microservice have a dependency relationship and a dependency condition.
[0069] S203, establishing a service combination model according to the calling order of the microservices, the dependency relationship and dependency condition between the microservices, the calling state of the plurality of microservices, the input parameters of the microservices, and the output parameters of the microservices, and storing the service combination model to the configuration center based on the business identifier of the business service.
[0070] After the calling order of the microservices is established, the output parameters of the previous microservice are the input parameters of the next microservice, and then the service combination model is established according to the calling order of the microservices, the dependency relationship and dependency condition between the microservices, the calling state of the plurality of microservices, the input parameters of the microservices, and the output parameters of the microservices.
[0071] It is considered that each microservice has a corresponding calling state. Therefore, the calling state of the microservice also needs to be considered in the process of establishing the service combination model.
[0072] In the case that the calling state of the microservice includes callable, the service combination model can be established according to the calling sequence of the microservice, the dependency relationship and the dependency condition between the microservices, the calling state of the multiple microservices, the input parameter of the microservice and the output parameter of the microservice.
[0073] In the case that the calling state of the microservice includes prohibited calling, the callable microservice that replaces the prohibited calling microservice can be filtered out according to the business logic of the business service. Then, the service combination model can be established according to the calling sequence of the callable microservice, the dependency relationship and the dependency condition between the callable microservices, the calling state of the callable microservice, the input parameter of the callable microservice and the output parameter of the callable microservice.
[0074] In the case that the calling state of the microservice includes prohibited calling, the callable microservice that replaces the prohibited calling microservice is not filtered out according to the business logic of the business service. Then, considering that the calling state of the microservice will be updated, the service combination model can be established according to the calling sequence of the microservice, the dependency relationship and the dependency condition between the microservices, the calling state of the multiple microservices, the input parameter of the microservice and the output parameter of the microservice. After obtaining the service combination model, the calling state of the prohibited calling microservice needs to be updated to ensure the use of the service combination model.
[0075] The service combination model corresponds to the business service. That is, different business services correspond to different service combination models. The business service is the same, and the service combination model is the same. For the same business service, the same service combination model can be used, and it is not necessary to repeatedly establish the service combination model, thereby improving the calling accuracy of the business service and accelerating the calling speed of the microservice.
[0076] In the embodiment of the application, the service combination model is stored in the configuration center based on the business identifier of the business service. In this way, the service combination model can be obtained in the configuration center based on the business identifier of the business service.
[0077] In the embodiment of the application, Figure 2 In the embodiment of the application, the corresponding service combination model is established for the business service, thereby being capable of accelerating the calling accuracy and speed of the microservice.
[0078] Referring to Figure 3 i.e. 300, Figure 3is a schematic diagram of calling microservices for purchasing goods according to an embodiment of the present application. Specifically, when a user finishes shopping and prepares to pay, the user microservice, the shopping cart microservice, the goods microservice, the order microservice and the payment microservice are called. The calling states of the above microservices are all: callable. The role of each microservice is explained below.
[0079] The user microservice: verifies the identity and authority of the user.
[0080] The shopping cart microservice: obtains the shopping cart information of the user, including the list of goods and the quantity.
[0081] The goods microservice: verifies whether the goods in the shopping cart are still available, and obtains the latest goods information.
[0082] The order microservice: creates an order according to the shopping cart information, and sets an initial state. As an example, the initial state includes: to be paid.
[0083] The payment microservice: handles the payment logic, interacts with the third-party payment platform, and completes the payment process.
[0084] After the above microservices are executed in sequence, the payment is successful, the order state is updated to "paid", and the subsequent logistics or delivery process is triggered.
[0085] Referring to Figure 4 that is 400, Figure 4 is a schematic diagram of the dependency relationship between microservices according to an embodiment of the present application.
[0086] The order microservice depends on the user microservice to verify the user identity. Both the order microservice and the shopping cart microservice depend on the goods microservice to obtain and verify the goods information. The payment microservice can be independent of other microservices, but the payment microservice needs to interact with the order microservice to confirm the payment state and update the order. The shopping cart microservice depends on the user microservice to manage the shopping cart of the user.
[0087] In an embodiment of the present application, as the microservices in the business service are adjusted, the service composition model of the business service also needs to be adjusted. Specifically, the service composition model of the business service is updated according to the adjusted microservices of the business service and the business relationship between the adjusted microservices, and the service composition model of the business service of the configuration center is replaced by the updated service composition model of the business service.
[0088] In this way, the latest service composition model corresponding to the business service is stored in the configuration center. By updating the service composition model, the adjustment of the microservices is applicable.
[0089] S102, in response to the execution request of the business service, after the execution request of the business service is authenticated, the service combination model is obtained from the configuration center based on the business identifier of the business service, and the service list data of the business service is generated by combining the execution request of the business service and analyzing the service combination model.
[0090] The user sends an execution request of a business service for executing the business service. In order to improve the effectiveness of calling the business service, it is necessary to authenticate the execution request of the business service. After the execution request of the business service is authenticated, in response to the execution request of the business service, the service combination model is obtained from the configuration center based on the business identifier of the business service. The service list data of the business service is generated by combining the execution request of the business service and analyzing the service combination model. The service list data is an instantiation of the service combination model.
[0091] Referring to Figure 5 That is 500, Figure 5 is a flowchart of generating service list data of a business service by combining an execution request of the business service and analyzing a service combination model according to an embodiment of the application. Specifically, it includes the following steps.
[0092] S501, in response to the execution request of the business service, after the execution request of the business service is authenticated based on the business identifier of the business service, the service combination model is obtained from the configuration center based on the business identifier of the business service, and the service list data of the business service is generated by combining the execution request of the business service and analyzing the service combination model.
[0093] The business identifier of the business service is obtained from the execution request of the business service. The execution request of the business service is authenticated according to the business identifier of the business service. As an example, the business identifier of the business service has the permission to call the service combination model, then the execution request of the business service is authenticated; the business identifier of the business service does not have the permission to call the service combination model, then the execution request of the business service is not authenticated. For example, the authentication of the execution request of the business service is realized by white list.
[0094] Further, the service combination model is obtained from the configuration center based on the business identifier of the business service. As an example, the service combination model is stored in the configuration center in the form of a table.
[0095] The service combination model is analyzed, and the microservices of the business service, the calling sequence of the microservices, the calling state of the microservices, the dependency relationship of the microservices and the dependency conditions of the microservices are obtained. Among them, the calling sequence of the microservices, the dependency relationship of the microservices and the dependency conditions of the microservices belong to the cooperation mechanism among the microservices.
[0096] The calling state of the microservice can be learned based on the identification of the microservice of the business service.
[0097] S502, according to the execution request of the business service, the dependency relationship of the microservice, the dependency condition of the microservice and the calling state of the microservice, the execution microservice of the business service is screened out.
[0098] In the embodiments of the present application, the microservice can be divided into execution microservice and dependent microservice. The execution microservice is the microservice that processes the execution request. The dependent microservice is the microservice that provides data.
[0099] As an example, the business service involves user microservice, shopping cart microservice, commodity microservice, order microservice and payment microservice. The execution microservice includes: shopping cart microservice, order microservice and payment microservice. The dependent microservice includes user microservice and commodity microservice.
[0100] Specifically, according to the execution request of the business service, the dependency relationship of the microservice, the dependency condition of the microservice and the calling state of the microservice, the execution microservice of the business service is screened out. As an example, the calling state of the microservice of the business service is determined to include: callable. The microservice that processes the execution request is taken as the execution microservice. The microservice that has dependency relationship and dependency condition with the execution microservice is taken as the dependent microservice. As another example, the calling state of the microservice of the business service is determined to include: forbidden calling, which means that the microservice of the business service is unavailable, and the calling of the business service is stopped. In order to guarantee the calling of the business service, the calling state of the microservice can be updated by a preset period when the calling state of the microservice of the business service is determined to include: forbidden calling. When the calling state of the microservice of the business service is determined to include: callable, the microservice that processes the execution request is taken as the execution microservice. The microservice that has dependency relationship and dependency condition with the execution microservice is taken as the dependent microservice.
[0101] S503, according to the calling sequence of the execution microservice, the service list data of the business service is constructed.
[0102] Based on the calling sequence of the microservice, the calling sequence of the execution microservice is further obtained. According to the calling sequence of the execution microservice, the service list data of the business service is constructed. As an example, according to the calling sequence of the execution microservice, the instantiation code block of the execution microservice is executed, and the service list data of the business service is generated. As an example, the service list data of the business service is json format data.
[0103] The service list data of the business service can realize the instantiation of the execution request of the business service. The service list data is the running state data, which clearly shows the execution sequence of each microservice. Through the service list data, the calling process of the microservice can be accurately controlled.
[0104] In Figure 5 In an embodiment of the application, the instantiation of the execution request of the business service is implemented by using the service combination model.
[0105] Referring to Figure 6 That is, 600, Figure 6 is a flowchart for constructing the service list data of the business service according to the calling order of the microservices in the execution of the microservices according to an embodiment of the application. Specifically, the following steps are included.
[0106] S601, according to the execution request of the business service, the execution microservices are divided into multiple business execution groups.
[0107] In an embodiment of the application, considering that the number of microservices involved in the business service is large, in order to quickly establish the data of the service list data, the execution microservices can be divided into multiple business execution groups according to the execution request of the business service.
[0108] As an example, according to the process of the execution request of the business service, the execution microservices are divided into multiple business execution groups. For example, the microservices in the first process are divided into a first business execution group; the microservices in the second process are divided into a second business execution group; and the microservices in the third process are divided into a third business execution group.
[0109] S602, according to the execution microservices in the business execution group and the calling order of the execution microservices, the service list data of the business execution group is constructed.
[0110] For each business execution group, according to the execution microservices in the business execution group and the calling order of the execution microservices, the service list data of the business execution group is constructed. That is, the corresponding service list data is established for each business execution group.
[0111] S603, according to the calling order of the microservices and the service list data of the business execution group, the service list data of the business service is established.
[0112] According to the calling order of the microservices, the order of the service list data of the business execution group can be determined. Further, according to the order of the service list data of the execution group and the service list data of the business execution group, the service list data of the business service is established.
[0113] In Figure 6 In an embodiment of the application, the service list data of the business service is established by grouping, and then the business service is executed by the service list data of multiple business execution groups.
[0114] S103, according to the service list data of the business service, the execution order of the microservice is known and the microservice is called in turn according to the execution order of the microservice, and the execution state of the microservice is adjusted to process the execution request of the business service.
[0115] After obtaining the service list data of the business service, the engine knows the execution order of the microservice and calls the microservice in turn according to the execution order of the microservice, and adjusts the execution state of the microservice to process the execution request of the business service. That is, the engine processes the execution request of the business service according to the service list data of the business service.
[0116] Referring to Figure 7 That is 700, Figure 7 is a flowchart of adjusting the execution state of the microservice to process the execution request of the business service according to an embodiment of the application. Specifically, it includes the following steps.
[0117] S701, based on the service list data of the business service, the execution order of the microservice and the dependency condition of the microservice are obtained, and the execution state of the microservice is adjusted according to the dependency condition of the microservice.
[0118] In an embodiment of the application, the engine obtains the execution order of the microservice and the dependency condition of the microservice based on the service list data of the business service, and adjusts the execution state of the microservice according to the dependency condition of the microservice.
[0119] The dependency condition of the microservice is the prerequisite for the execution of the microservice. As an example, the dependency condition of the order microservice is to obtain user information from the user microservice and obtain commodity information from the commodity microservice.
[0120] In an embodiment of the application, the execution state of the microservice includes ready, running, blocking and failure. In the case of ready and running, it means that the microservice processes the execution request normally; in the case of blocking and failure, it means that the microservice processes the execution request abnormally.
[0121] Based on the service list data of the business service, the execution order of the microservice and the dependency condition of the microservice are obtained, and the execution state of the microservice can be adjusted according to the dependency condition of the microservice.
[0122] As an example, the dependency condition of the microservice is satisfied and the execution request has not been processed, and the execution state of the microservice is adjusted to: ready.
[0123] The dependency condition of the microservice is satisfied and the execution request is being processed, and the execution state of the microservice is adjusted to: running.
[0124] The dependency condition of the microservice is not satisfied or the execution request is processed once abnormally, and the execution state of the microservice is adjusted to: blocking.
[0125] If the dependency condition of the microservice is not met or the processing execution request multiple times is abnormal, the execution state of the microservice is adjusted to: failure.
[0126] S702, according to the execution order of the microservice and the execution state of the microservice, the microservice is called to process the execution request of the business service.
[0127] Each microservice has an execution order and an execution state, and the engine can call the microservice to process the execution request of the business service according to the execution order of the microservice and the execution state of the microservice.
[0128] Referring to Figure 8 That is 800, Figure 8 is a flowchart of calling the blocked or failed microservice again according to the exception handling operation according to an embodiment of the application. Specifically, the following steps are included.
[0129] S801, the execution state of the microservice includes blocking or failure, and based on the blocked or failed microservice and the execution request, the configuration center is queried to obtain the exception handling operation.
[0130] In the case where the execution state of the microservice includes ready or running, the microservice can be directly called to process the execution request of the business service.
[0131] In the case where the execution state of the microservice includes blocking or failure, it means that the microservice cannot normally process the execution request of the business service, and the exception handling operation needs to be obtained from the configuration center. The exception handling operation is preset in the configuration center based on the identification of the microservice.
[0132] Specifically, in the case where the execution state of the microservice includes blocking or failure, the configuration center is queried based on the blocked or failed microservice and the execution request to obtain the exception handling operation.
[0133] S802, the blocked or failed microservice is called again according to the exception handling operation to continue processing the execution request of the business service.
[0134] After obtaining the exception handling operation from the configuration center, the blocked or failed microservice is called again according to the exception handling operation to continue processing the execution request of the business service.
[0135] In an embodiment of the application, the exception handling operation includes: a retry strategy and a skip failed microservice strategy. As an example, in the application scenario of online payment, the retry strategy will be executed due to the network fluctuation leading to the first call failure.
[0136] Retry strategy: preset maximum retry number and retry time interval. When the microservice call fails, check whether the retry number has reached the maximum retry number. If the maximum retry number is not reached, wait for the retry time interval and retry again. If the microservice call still fails after the maximum retry number is reached, the skip strategy is executed.
[0137] Skip strategy: identify microservices that can be skipped in the service list data. In the case of calling microservices that can be skipped, if the call to the microservice fails, record the failure information, but do not interrupt the execution request for processing the business service in the next microservice.
[0138] In the above embodiment of the application, the service combination model of the business service is constructed based on the multiple microservices involved in the business service, the business relationship between the multiple microservices, and the call state of the multiple microservices, and the service combination model is stored in the configuration center. In response to the execution request of the business service, after the execution request of the business service is authenticated, the service combination model is obtained from the configuration center based on the business identifier of the business service, and the service list data of the business service is generated by parsing the service combination model in combination with the execution request of the business service. According to the service list data of the business service, the execution order of the microservices is obtained, and the microservices are called in sequence according to the execution order of the microservices, and the execution state of the microservices is adjusted to process the execution request of the business service. The service combination model of the business service can preset the microservices for implementing the business service, so as to reduce the business logic error and avoid service call failure or performance decline.
[0139] Referring to Figure 9 , Figure 9 is the main structure diagram of the device for calling a business service according to an embodiment of the application. The device for calling a business service can implement the method for calling a business service, such as Figure 9 As shown in 900, the device for calling a business service specifically includes:
[0140] The construction module 901 is configured to construct a service combination model of the business service based on multiple microservices involved in the business service, a business relationship between the multiple microservices, and a call state of the multiple microservices, and store the service combination model in a configuration center.
[0141] The parsing module 902 is configured to, in response to an execution request of the business service, after the execution request of the business service is authenticated, obtain the service combination model from the configuration center based on a business identifier of the business service, and generate service list data of the business service by parsing the service combination model in combination with the execution request of the business service.
[0142] The execution module 903 is configured to know the execution sequence of the microservices according to the service list data of the business service, and sequentially call the microservices according to the execution sequence of the microservices, and adjust the execution state of the microservices to process the execution request of the business service.
[0143] In an embodiment of the present application, the construction module 901 is specifically configured to filter out a plurality of microservices involved in the business service according to the business logic of the business service, and determine the calling state of the plurality of microservices;
[0144] The calling sequence of the microservices is determined based on the business logic sequence in the business relationship among the plurality of microservices, and the dependency relationship and dependency condition between the microservices are determined according to the data flow of the microservices in the business relationship among the plurality of microservices;
[0145] The service combination model is established according to the calling sequence of the microservices, the dependency relationship and dependency condition between the microservices, the calling state of the plurality of microservices, the input parameters of the microservices and the output parameters of the microservices, and the service combination model is stored in the configuration center based on the business identifier of the business service.
[0146] In an embodiment of the present application, the parsing module 902 is specifically configured to, in response to the execution request of the business service, after the execution request of the business service is authenticated according to the business identifier of the business service, acquire the service combination model from the configuration center based on the business identifier of the business service, parse the service combination model to know the microservices of the business service, the calling sequence of the microservices, the calling state of the microservices, the dependency relationship of the microservices and the dependency condition of the microservices;
[0147] According to the execution request of the business service, the dependency relationship of the microservices, the dependency condition of the microservices and the calling state of the microservices, the execution microservices of the business service are filtered out;
[0148] The service list data of the business service is constructed according to the calling sequence of the execution microservices.
[0149] In an embodiment of the present application, the parsing module 902 is specifically configured to divide the execution microservices into a plurality of business execution groups according to the execution request of the business service;
[0150] The service list data of the business execution group is constructed according to the execution microservices in the business execution group and the calling sequence of the execution microservices.
[0151] The service list data of the business service is established according to the calling sequence of the microservices and the service list data of the business execution group.
[0152] In one embodiment of the present invention, the execution module 903 is specifically used to obtain the execution order of the microservice and the dependency conditions of the microservice based on the service list data of the business service, and adjust the execution state of the microservice according to the dependency conditions of the microservice.
[0153] According to the execution order and execution status of the microservices, the microservices are invoked to process the execution request of the business service.
[0154] In one embodiment of the present invention, the execution module 903 is specifically used to query the configuration center to obtain exception handling operations based on the blocked or failed microservice and the execution request, if the execution status of the microservice includes blocking or failure.
[0155] The blocked or failed microservice is invoked again according to the exception handling operation to continue processing the execution request of the business service.
[0156] In one embodiment of the present invention, the construction module 901 is further configured to update the service composition model of the business service based on the business relationship between the microservice adjusted by the business service and the adjusted microservice, and replace the service composition model of the business service in the configuration center with the updated service composition model of the business service.
[0157] Figure 10 An exemplary system architecture 1000 is shown, in which the method or apparatus for invoking a business service can be applied according to embodiments of the present invention.
[0158] like Figure 10 As shown, system architecture 1000 may include terminal devices 1001, 1002, and 1003, network 1004, and server 1005. Network 1004 is used as a medium to provide communication links between terminal devices 1001, 1002, and 1003 and server 1005. Network 1004 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0159] Users can use terminal devices 1001, 1002, and 1003 to interact with server 1005 via network 1004 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 1001, 1002, and 1003, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0160] Terminal devices 1001, 1002, and 1003 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0161] The server 1005 can be a server that provides various services, such as a background management server that provides support for a shopping website browsed by a user using the terminal device 1001, 1002, 1003 (only as an example). The background management server can analyze and process received product information query request and other data, and feed back the processing result (such as target push information, product information - only as an example) to the terminal device.
[0162] It should be noted that the method for calling a service provided by the embodiment of the present application is generally executed by the server 1005, and accordingly, the device for calling a service is generally arranged in the server 1005.
[0163] It should be understood that Figure 10 The number of terminal devices, networks and servers in the system shown in
[0164] The embodiment of the present application is a kind of computing program product, including computer program, the program is executed by processor to realize the method for calling the service provided by the embodiment of the present application.
[0165] Reference will now be made to Figure 11 which shows a structural schematic diagram of a computer system 1100 of a terminal device suitable for use to implement the embodiment of the present application. Figure 11 The terminal device shown is only an example, and should not bring any limitation to the function and use range of the embodiment of the present application.
[0166] As shown in Figure 11 The computer system 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 1102 or programs loaded from a storage portion 1108 into a random access memory (RAM) 1103. Various programs and data required for the operation of the system 1100 are also stored in the RAM 1103. The CPU 1101, the ROM 1102 and the RAM 1103 are connected to each other through a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0167] The following components are connected to the I / O interface 1105: an input part 1106 including a keyboard, a mouse, etc.; an output part 1107 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage part 1108 including a hard disk, etc.; and a communication part 1109 including a network interface card such as a LAN card, a modem, etc. The communication part 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as necessary. A removable media 1111 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 1110 as necessary, so that a computer program read out therefrom is installed in the storage part 1108 as necessary.
[0168] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication part 1109, and / or installed from the removable media 1111. When the computer program is executed by the central processing unit (CPU) 1101, the above-described functions defined in the system of the present disclosure are executed.
[0169] It should be noted that the computer-readable medium shown in the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or component. In the present application, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or component. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0170] The flowcharts and block diagrams in the drawings illustrate the possible implementation architectures, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment or a part of code containing one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different order than that shown in the drawings. For example, two blocks that are shown in succession can actually be executed substantially in parallel, and sometimes in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams or flowcharts, and the combination of blocks in the block diagrams or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0171] The modules described in the embodiments of the present application can be implemented in the form of software or hardware. The described modules can also be arranged in a processor, for example, a processor can be described as including a constructing module, an analyzing module and an executing module. In some cases, the names of these modules do not constitute a limitation on the modules themselves, for example, the constructing module can also be described as "a module configured to construct a service composition model of a business service based on a plurality of microservices involved in the business service, a business relationship between the plurality of microservices and a calling state of the plurality of microservices, and store the service composition model in a configuration center".
[0172] As another aspect, the present application also provides a computer readable medium, which can be included in the device described in the above embodiments, or can exist independently without being assembled into the device. The computer readable medium carries one or more programs, which, when executed by the device, cause the device to include:
[0173] constructing a service composition model of a business service based on a plurality of microservices involved in the business service, a business relationship between the plurality of microservices and a calling state of the plurality of microservices, and storing the service composition model in a configuration center;
[0174] in response to an execution request of the business service, after the execution request of the business service is authenticated, obtaining the service composition model from the configuration center based on a business identifier of the business service, and generating service list data of the business service by analyzing the service composition model in combination with the execution request of the business service;
[0175] according to the service list data of the business service, obtaining an execution order of the microservices and sequentially calling the microservices according to the execution order of the microservices, and adjusting an execution state of the microservices to process the execution request of the business service.
[0176] According to the technical scheme of the embodiment of the application, a service combination model of a business service is constructed based on a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and the service combination model is stored in a configuration center; in response to an execution request of the business service, after the execution request of the business service is authenticated, the service combination model is obtained from the configuration center based on a business identifier of the business service, the service combination model is parsed in combination with the execution request of the business service to generate service list data of the business service; and according to the service list data of the business service, an execution sequence of the microservices is known, and the microservices are called in sequence according to the execution sequence of the microservices, and an execution state of the microservices is adjusted to process the execution request of the business service. The microservices are called according to the service combination model to process the execution request of the business service, the sequence and the execution state of the microservices are controllable, and thus the business logic error can be reduced, and service calling failure or performance degradation can be avoided.
[0177] The specific embodiments described above do not constitute a limitation of the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principles of the present application shall fall within the protection scope of the present application.
[0178] It should be noted that in the technical scheme of the present application, the collection, analysis, use, transmission, storage, etc. of user personal information involved in the technical scheme of the present application comply with relevant laws and regulations, are used for legal and reasonable purposes, are not shared, disclosed, or sold outside these legal uses, and are subject to supervision and management by regulatory authorities. Necessary measures should be taken for user personal information to prevent illegal access to such personal information data, to ensure that personnel with access to personal information data comply with relevant laws and regulations, and to ensure the security of user personal information. Once these user personal information data are no longer needed, the risk should be minimized by limiting or even prohibiting data collection and / or deleting data.
[0179] When applicable, including in certain related applications, user privacy is protected by de-identifying data, such as by removing specific identifiers (e.g., birth date, etc.), controlling the amount or specificity of data stored (e.g., collecting location data at the city level rather than at the specific address level), controlling how data is stored, and / or other methods of de-identification, as applicable.
Claims
1. A method of invoking a business service, characterized by, The method comprises the following steps: constructing a service combination model of the business service according to a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and storing the service combination model to a configuration center; in response to an execution request of the business service, after the execution request of the business service is authenticated, the service combination model is obtained from the configuration center based on a business identifier of the business service, the service combination model is parsed in combination with the execution request of the business service to generate service list data of the business service; according to the service list data of the business service, the execution order of the microservices is known, and the microservices are called in sequence according to the execution order of the microservices, and the execution state of the microservices is adjusted to process the execution request of the business service.
2. The method of invoking a business service of claim 1, wherein, The method of constructing a service combination model of the business service according to a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and storing the service combination model to a configuration center comprises: According to the business logic of the business service, the plurality of microservices involved in the business service are filtered, and the calling state of the plurality of microservices is determined; determine the calling order of the microservices based on the business logic order in the business relationship between the plurality of microservices, and determine the dependency relationship and dependency condition between the microservices according to the data flow of the microservices in the business relationship between the plurality of microservices; According to the calling order of the microservices, the dependency relationship and dependency condition between the microservices, the calling state of the plurality of microservices, the input parameters of the microservices and the output parameters of the microservices, the service combination model is established, and the service combination model is stored to the configuration center based on the business identifier of the business service.
3. The method of invoking a business service of claim 1, wherein, The method of constructing a service combination model of the business service according to a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and storing the service combination model to a configuration center comprises: In response to the execution request of the business service, after the execution request of the business service is authenticated, the service combination model is obtained from the configuration center based on the business identifier of the business service, the service combination model is parsed in combination with the execution request of the business service to generate service list data of the business service; According to the execution request of the business service, the dependency relationship of the microservices, the dependency condition of the microservices and the calling state of the microservices, the execution microservices of the business service are filtered; According to the calling order of the execution microservices, the service list data of the business service is constructed.
4. The method of invoking a business service according to claim 3, wherein, The method of constructing a service combination model of the business service according to a plurality of microservices involved in the business service, a business relationship between the plurality of microservices, and a calling state of the plurality of microservices, and storing the service combination model to a configuration center comprises: According to the execution request of the business service, the execution microservices are divided into a plurality of business execution groups; construct service list data of the business service according to the execution microservices in the business execution group and the calling sequence of the execution microservices; establish service list data of the business service according to the calling sequence of the microservices and the service list data of the business execution group.
5. The method of invoking a business service of claim 1, wherein, According to the service list data of the business service, the execution sequence of the microservices is known and the microservices are called in sequence according to the execution sequence of the microservices, and the execution state of the microservices is adjusted to process the execution request of the business service, including: According to the service list data of the business service, the execution sequence of the microservices and the dependency conditions of the microservices are obtained, and the execution state of the microservices is adjusted according to the dependency conditions of the microservices; According to the execution sequence of the microservices and the execution state of the microservices, the microservices are called to process the execution request of the business service.
6. The method of invoking a service according to claim 5, wherein, According to the execution sequence of the microservices and the execution state of the microservices, the microservices are called to process the execution request of the business service, including: If the execution state of the microservice includes blocking or failure, the configuration center is queried based on the blocked or failed microservice and the execution request to obtain an exception handling operation; According to the exception handling operation, the blocked or failed microservice is called again to continue processing the execution request of the business service.
7. The method of invoking a business service of claim 1, wherein, The method further comprises: The service combination model of the business service is updated according to the business relationship between the adjusted microservices of the business service and the adjusted microservices, and the service combination model of the business service in the configuration center is replaced by the updated service combination model of the business service.
8. An apparatus for invoking a business service, characterized by including: The construction module is configured to construct the service combination model of the business service according to a plurality of microservices involved in the business service, business relationships between the plurality of microservices, and calling states of the plurality of microservices, and store the service combination model in the configuration center; The parsing module is configured to, in response to an execution request of the business service, after the execution request of the business service is authenticated, obtain the service combination model from the configuration center based on a business identifier of the business service, and parse the service combination model to generate service list data of the business service in combination with the execution request of the business service; The execution module is configured to, according to the service list data of the business service, know the execution sequence of the microservices and call the microservices in sequence according to the execution sequence of the microservices, and adjust the execution state of the microservices to process the execution request of the business service.
9. An electronic device that invokes a business service, the electronic device comprising: including: one or more processors; storage means for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any one of claims 1-7.
10. A computer readable medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method of any one of claims 1-7.
11. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the method of any one of claims 1-7.
Citation Information
Patent Citations
Data service providing method and device, medium and electronic equipment
CN114816791A
Task processing method and device
CN116483560A