Business processing method and related device based on microservice architecture
By building and storing the return code mapping relationship in the microservice architecture, the problem of slow return code update speed and high cost is solved, and fast and low-cost return code updates are achieved.
Patent Information
- Application Number
- CN202310792820.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-29
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2043-06-29
AI Technical Summary
In the microservice architecture, the return code is updated slowly and has high update cost, especially when the return code changes, the configuration information of the microservice unit and the microservice gateway needs to be updated.
Pre-construct the return code mapping relationship between the business client, microservice unit and business server, and store it in the database. Transcoding operations are performed by calling the mapping relationship to avoid updating configuration information in the microservice unit and the microservice gateway.
It realizes rapid update of return codes, reduces update costs and time, and improves system flexibility and efficiency.
Smart Images

Figure CN116708570B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of distributed architecture, and in particular to a business processing method and related devices based on a microservice architecture. Background Art
[0002] The microservices architecture is a variation of the Service-Oriented Architecture (SOA). It advocates dividing a single application into a set of small services that coordinate and collaborate with each other to deliver ultimate value to users. As a distributed architecture, the microservices architecture offers advantages such as flexible scalability, high availability, unlimited concurrency, and low cost. Each microservice unit in a microservices architecture provides only atomic-level services that can be called by all peripheral products. For example, a login interface can be called by each external business module without requiring separate implementation.
[0003] During business processing within a microservices architecture, return codes are exchanged between microservice units, business clients, and business servers to provide feedback to various systems on business processing results. However, at the interface interaction level between microservice units, business clients, and business servers, each system defines return codes using different rules and methods. To ensure that systems can recognize return codes sent by other systems, return code transcoding is required to convert them into return codes recognizable by the current system.
[0004] The existing business processing method is to configure the return code and the return code transcoding rules in the microservice unit and the microservice gateway. However, when the return code changes, the configuration information of the microservice unit and the microservice gateway needs to be updated to complete the update of the return code, which has the problems of slow update speed and high update cost. Summary of the Invention
[0005] The present application provides a business processing method and related devices based on a microservice architecture, which are used to solve the problems of slow return code update speed and high update cost when the return code changes in the existing microservice architecture.
[0006] In a first aspect, the present application provides a business processing method based on a microservice architecture, which is applied to a microservice unit, comprising:
[0007] receiving a first return code returned by the business service end; wherein the first return code is an identifier generated according to a processing result of the target business by the business service end, the business service end includes multiple business functions, and the target business corresponds to one of the business functions;
[0008] Reading a first mapping relationship from a database, and transcoding the first return code according to the first mapping relationship to obtain a second return code;
[0009] Sending the second return code to the microservice gateway, where the second return code is used by the microservice gateway to read the first mapping relationship from the database, and transcoding the second return code according to the first mapping relationship to obtain a third return code;
[0010] The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
[0011] In a second aspect, the present application provides a business processing method based on a microservice architecture, which is applied to a microservice gateway, including:
[0012] Receive a second return code returned by the microservice unit; wherein the second return code is obtained by the microservice unit reading a first mapping relationship from a database and transcoding a first return code returned by the business service end according to the first mapping relationship; the first return code is an identifier generated based on a processing result of the target business by the business service end; the business service end includes multiple business functions, and the target business corresponds to one of the business functions;
[0013] Reading the first mapping relationship from the database, and transcoding the second return code according to the first mapping relationship to obtain a third return code;
[0014] Sending the third return code to the business client;
[0015] The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
[0016] In a third aspect, the present application provides a business processing device of a microservice architecture, which is applied to a microservice unit, including:
[0017] a first receiving module, configured to receive a first return code returned by the business server; wherein the first return code is an identifier generated according to a processing result of the target business by the business server, the business server including multiple business functions, and the target business corresponding to one of the business functions;
[0018] a first transcoding module, configured to read a first mapping relationship from a database, and transcode the first return code according to the first mapping relationship to obtain a second return code;
[0019] A first sending module is configured to send the second return code to the microservice gateway, where the second return code is used by the microservice gateway to read the first mapping relationship from the database and transcode the second return code according to the first mapping relationship to obtain a third return code;
[0020] The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
[0021] In a fourth aspect, the present application provides a business processing device of a microservice architecture, which is applied to a microservice gateway, including:
[0022] a second receiving module, configured to receive a second return code returned by the microservice unit; wherein the second return code is obtained by the microservice unit reading a first mapping relationship from a database and transcoding a first return code returned by the business service end according to the first mapping relationship; the first return code is an identifier generated based on a processing result of the target business by the business service end; the business service end includes multiple business functions, and the target business corresponds to one of the business functions;
[0023] a second transcoding module, configured to read the first mapping relationship from the database, and transcode the second return code according to the first mapping relationship to obtain a third return code;
[0024] A second sending module, configured to send the third return code to the service client;
[0025] The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
[0026] In a fifth aspect, the present application provides a microservice system, which includes a business client, a microservice gateway, a microservice unit, a business service end, and a database; wherein:
[0027] The business service end is used to send a first return code to the microservice unit; wherein the first return code is an identifier generated according to the processing result of the target business by the business service end, the business service end includes multiple business functions, and the target business corresponds to one of the business functions;
[0028] The microservice unit is configured to receive the first return code returned by the business service end, read the first mapping relationship from the database, and transcode the first return code according to the first mapping relationship to obtain a second return code;
[0029] The microservice gateway is configured to receive the second return code returned by the microservice unit, read the first mapping relationship from a database, and transcode the second return code according to the first mapping relationship to obtain a third return code;
[0030] The business client is used to receive a third return code returned by the microservice gateway;
[0031] The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
[0032] In a sixth aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0033] The memory stores computer-executable instructions;
[0034] The processor executes the computer-executable instructions stored in the memory to implement the method described in the first aspect or the second aspect.
[0035] In a seventh aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect or the second aspect.
[0036] In an eighth aspect, the present application provides a computer program product, comprising a computer program, which is used to implement the method described in the first aspect or the second aspect when executed by a processor.
[0037] The business processing method and related device based on the microservice architecture provided by the present application pre-build the mapping relationship of the return codes between the business client, the business microservice unit and the business service end, and store the mapping relationship in the database. Then, by calling the mapping relationship, it is used to transcode the return code in the business processing process, thereby realizing the return code identification between different systems. When the return code in the microservice architecture changes, it is only necessary to update the mapping relationship of the return code in the database to quickly update the return code of the microservice architecture. There is no need to update the return code by modifying the configuration information of the microservice unit and the microservice gateway. The update cost of the return code is lower and the update speed is faster. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] 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.
[0039] Figure 1 A schematic diagram of the architecture of a microservice system provided in an embodiment of the present application;
[0040] Figure 2 A flowchart of a business processing method based on a microservice architecture provided in an embodiment of the present application;
[0041] Figure 3 A flowchart of another business processing method based on a microservice architecture provided in an embodiment of the present application;
[0042] Figure 4 A flowchart of another business processing method based on a microservice architecture provided in an embodiment of the present application;
[0043] Figure 5 A schematic diagram of the structure of a business processing device with a microservice architecture provided in an embodiment of the present application;
[0044] Figure 6 A schematic diagram of the structure of another business processing device with a microservice architecture provided in an embodiment of the present application;
[0045] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0046] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0047] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0048] It should be noted that the business processing method and related devices based on the microservice architecture of the present application can be used in the field of distributed architecture, and can also be used in any field other than the field of distributed architecture. The application field of the business processing method and related devices based on the microservice architecture of the present application is not limited.
[0049] When it comes to computer network architecture, in terms of system design and implementation, the traditional centralized architecture is limited by the performance of a single database, and its maximum concurrent performance has a natural bottleneck limitation. If you want to improve its performance, you need to start with the hardware equipment and adopt higher-performance and more expensive hardware equipment.
[0050] Taking electronic payment as an example, with the development of information technology, social life is becoming increasingly digitalized. A prominent manifestation of this is the shift to online payment methods. People are becoming increasingly accustomed to online shopping, which has also led to significant changes in business models, production and lifestyles. This common practice of online payment is placing increasing pressure on the electronic payment systems of large commercial banks and payment institutions. This pressure can reach peak levels during certain shopping activities, and any system anomalies can have extremely negative impacts on users and society.
[0051] Therefore, the current mainstream system architecture design has shifted to a distributed architecture oriented towards microservices, which has the advantages of flexible expansion, high availability, unlimited concurrency, and low cost.
[0052] The design concept of microservices is atomization, providing only the most primitive service units. For example, electronic payment services only implement functions related to deductions during payment, without any other business logic. When other peripheral business modules involve user payments, they can directly call the service without having to implement it separately.
[0053] Due to the independence of each microservice unit, the rules and methods for defining return codes vary between microservice units, business clients, and business servers at the interface interaction level. To enable systems to recognize return codes sent by other systems, they must transcode the return codes according to their interface specifications to convert them into return codes recognizable by the current system.
[0054] The existing business processing method is to configure the return code transcoding rules within the microservice unit and microservice gateway. However, when the return code changes, such as when the return code on the business server is added, deleted, or modified, the configuration information of the microservice unit and microservice gateway must be updated to complete the return code update. Updating the configuration information is generally completed by issuing new versions of the microservice unit application and the microservice gateway application. This has the problem of slow update speed and high update cost.
[0055] In response to the above technical problems, this application pre-builds the mapping relationship of return codes between the business client, business microservice unit and business service end, and stores the mapping relationship in the database. Then, by calling the mapping relationship, it is used to transcode the return code in the business processing process, thereby realizing the return code identification between different systems. When the return code in the microservice architecture changes, it only needs to update the mapping relationship of the return code in the database to quickly update the return code of the microservice architecture. There is no need to update the return code by modifying the configuration information of the microservice unit and the microservice gateway. The update cost of the return code is lower and the update speed is faster.
[0056] Next, combine Figure 1 , the architecture of the microservice system involved in this application is explained.
[0057] Figure 1 This is a schematic diagram of the structure of a microservice system provided by an embodiment of the present application. Figure 1 In some embodiments, the microservice system includes a business client 101, a microservice gateway 102, a microservice unit 103, a business service end 104, and a database 105.
[0058] The business service end 104 is used to send a first return code to the microservice unit 103; wherein the first return code is an identifier generated according to the processing result of the target business by the business service end 104, and the business service end 104 includes multiple business functions, and the target business corresponds to one of the business functions;
[0059] The microservice unit 103 is configured to receive a first return code returned by the business service end 104, read a first mapping relationship from the database 105, and transcode the first return code according to the first mapping relationship to obtain a second return code;
[0060] The microservice gateway 102 is configured to receive the second return code returned by the microservice unit 103, read the first mapping relationship from the database 105, and transcode the second return code according to the first mapping relationship to obtain a third return code;
[0061] The business client 101 is used to receive the third return code returned by the microservice gateway 102;
[0062] The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
[0063] In this embodiment, by storing the first mapping relationship in the database 105 and then calling it, the transcoding rules for the first return code and the second return code are no longer configured in the microservice unit 103, nor are the transcoding rules for the second return code and the third return code configured in the microservice gateway 102. When the return code changes, only the first mapping relationship in the database 105 needs to be updated to quickly update the return code. There is no need to issue a new version of the program application to replace the configuration information of the microservice unit 103 and the microservice gateway 102. This reduces the cost of updating the return code and increases the speed of updating.
[0064] Among them, the business client 101 is connected to the microservice gateway 102 via the network, the microservice gateway 102 is connected to the microservice unit 103 via the network, the microservice unit 103 is connected to the business server 104 via the network, and the microservice gateway 102 and the microservice unit 103 are also connected to the database 105 via the network. It should be noted that the network can be a wide area network or a local area network, or a combination of the two.
[0065] Among them, the business client 101 is the initiator of the request, representing the requester of the microservice, and is also the final recipient of the return code. The user enters the specific content of the request through the business client 101 and also receives the processing results returned by the business service end 104 through the business client 101.
[0066] Among them, the microservice gateway 102 is used to distribute the request initiated by the business client 101 to the corresponding microservice unit 103 for processing. Since each microservice unit 103 in the microservice system only provides a single business service, it is necessary to use the microservice gateway 102 to distribute the request of the business client 101 to a specific microservice unit 103 for processing.
[0067] Among them, the microservice unit 103 is a single business unit in the microservice system, which only provides a single business service and is used to process the request sent by the business client 101.
[0068] The business service end 104 is a processing system connected to the microservice unit 103 and represents the service provider invoked by the microservice unit 103. Specifically, taking the electronic payment service of a financial transaction as an example, the microservice unit 103 needs to access the interbank network channel for clearing services. The system corresponding to the interbank network channel is the business service end 104 for transaction processing.
[0069] Among them, the database 105 is used to store relevant data of business processing. In this application, the database 105 stores the mapping relationship between return codes, which is convenient for the microservice unit 103 and the microservice gateway 102 to call, so that the microservice unit 103 and the microservice gateway 102 can transcode the return code according to the return code mapping relationship.
[0070] Taking the electronic payment business as an example, the processing process of the microservice system is explained:
[0071] The user initiates a payment request on the business client 101 (electronic payment application, APP and other client programs). After receiving the payment request, the microservice gateway 102 distributes the request to the corresponding microservice unit 103 (electronic payment unit) for processing. Since the handling of electronic payment business requires calling the UnionPay system for clearing, the microservice unit 103 will continue to call the UnionPay system for processing after processing. The UnionPay system here is the business service end 104 of this application.
[0072] After the business service end 104 completes the target business processing, the business service end 104 will generate a return code based on the processing result and send it to the microservice unit 103. Since the microservice unit 103 has different return code definition rules and methods from the business service end 104, in order for the microservice unit 103 to recognize the return code sent by the business service end 104, it is necessary to read the first mapping relationship in the database 105 to transcode the return code. The transcoded return code of the microservice unit 103 will be sent to the microservice gateway 102. Since the microservice unit 103 also has different return code definition rules and methods from the business client 101, in order for the business client 101 to recognize the return code sent by the microservice unit 103, it is also necessary to read the first mapping relationship in the database 105 to transcode the return code of the microservice unit 103. The transcoding operation here is performed in the microservice gateway 102, and the transcoded return code will be sent to the business client 101. After receiving the return code, the business client 101 will display relevant processing information or error information according to the return code, such as "payment successful", "payment failed", etc., to facilitate users to understand the processing results of the microservice system and perform subsequent operations based on the processing results.
[0073] It should be noted that Figure 1 This is only a schematic diagram of the architecture of a microservice system provided by the embodiment of the present application. Figure 1 The actual form of the various devices included in the Figure 1 The interaction mode or connection mode between various devices is limited, and in the specific application of the technical solution, it can be set according to actual needs.
[0074] In some embodiments, the database stores the first mapping relationship in a database cache based on a database cache mechanism.
[0075] In this embodiment, the first mapping relationship is stored based on a database cache mechanism, which can greatly reduce the number of disk accesses, thereby improving the database reading performance. Common cache mechanisms include local cache, distributed cache, and memory cache, and the specific method to be adopted can be selected according to actual conditions. Specifically, the database cache mechanism refers to the technology of using cache in the database system to improve data reading performance. Specifically, when an application needs to read data from the database, it first queries the cache. If the data exists in the cache, it is returned directly; otherwise, the data is read from the database file on the disk and stored in the cache so that it can be retrieved faster the next time it is accessed.
[0076] Furthermore, since return codes may require updates, cache consistency must also be considered, specifically, whether the data in the cache is consistent with the actual database data. This allows for dynamic loading using the database cache mechanism, enabling appropriate caching mechanisms to reduce database query times. Next, a cache flush mechanism is used to trigger cache invalidation and reloading of the first mapping relationship when the return code is updated. This ensures that the latest data is automatically loaded on the next request, achieving automatic dynamic database loading.
[0077] Specifically, dynamic loading of the database cache mechanism refers to adjusting the cache strategy in real time at runtime based on access patterns and data usage to achieve better performance. Common dynamic loading strategies include:
[0078] Adaptive hash table: Dynamically adjusts the hash table size based on data access frequency, placing the most frequently accessed data in the shortest probe chain, thereby accelerating data search;
[0079] Least-Resource-Used (LRU) algorithm: determines the frequency of use of cached data based on the access time of the data, eliminates the data with the least access times, and thus retains the most useful data;
[0080] Most Recently Used (LFU) algorithm: determines the frequency of data use based on the number of times the data is accessed, eliminating the data with the least number of accesses, thereby retaining the data with the highest recent frequency of use;
[0081] Data prefetching: Based on access patterns and data relationships, prefetch likely-to-be-accessed data into the cache in advance, reducing wait time and improving hit rates.
[0082] These strategies are usually implemented within the database system and may vary depending on the database type and version. By optimizing these strategies, you can more effectively utilize the cache and improve database read performance.
[0083] In conjunction with the above-mentioned microservice system architecture, the technical solution of the business processing method based on the microservice architecture provided by this application is described in detail below through specific embodiments. It should be noted that the following embodiments can exist independently or in combination with each other, and the same or similar content may not be repeated in different embodiments.
[0084] Figure 2 A flowchart of a business processing method based on a microservice architecture provided in an embodiment of the present application is provided. Figure 2 In some embodiments, the business processing method based on the microservice architecture is applied to a microservice unit, and the process includes the following steps:
[0085] S201, receiving a first return code returned by the business server; wherein the first return code is an identifier generated according to the processing result of the target business by the business server, the business server includes multiple business functions, and the target business corresponds to one of the business functions.
[0086] The first return code is an identifier used by the service server to reflect the result of its processing. Different processing results correspond to different first return codes. Specifically, the processing result may include completion or an error. For example, in electronic payment services, the processing result may include payment success or payment failure, and different first return codes are associated with different failure reasons.
[0087] S202 : Read a first mapping relationship from a database, and transcode the first return code according to the first mapping relationship to obtain a second return code.
[0088] Among them, because the microservice unit is not directly sensitive to the specific errors reported by the business service end, nor is it directly sensitive to the externally defined return code requirements when external access is involved, a return code system based on the microservice's own logic is defined within the microservice unit.
[0089] Therefore, in order for the microservice unit to recognize the first return code returned by the business service end, it is necessary to transcode the first return code. The first mapping relationship stored in the database includes a mapping relationship between the first return code of the business service end and the second return code of the microprocessor unit. Based on the first mapping relationship, the first return code can be transcoded into a second return code that can be recognized by the microprocessor unit.
[0090] S203: Send the second return code to the microservice gateway. The second return code is used by the microservice gateway to read the first mapping relationship from the database, and transcode the second return code according to the first mapping relationship to obtain a third return code.
[0091] Since the return code definition rules and methods of the business client and the microservice unit are different, the business client needs to transcode the second return code returned by the microservice unit in order to recognize it, and the microservice gateway performs the transcoding operation on the second return code. Because the first mapping relationship stored in the data includes the mapping relationship between the second return code of the microservice system and the third return code of the business client, the microservice gateway can transcode the second return code according to the first mapping relationship, and transcode the second return code into the third return code that the business client can recognize.
[0092] The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
[0093] Preferably, the method for generating the first mapping relationship includes: defining the first return code of the business service end, the second return code of the microservice unit and the third return code of the business client; establishing a first mapping relationship between the first return code, the second return code and the third return code; and storing the first return code, the second return code, the third return code and the first mapping relationship in the database.
[0094] Among them, for the generation of the first mapping relationship, it is first necessary to define the first return code, the second return code, and the third return code. Specifically, the first return code, the second return code, and the third return code are defined based on the definition rules and methods of the return codes of the business service end, the microservice unit, and the business client, respectively. After the definition is completed, the first return code, the second return code, and the third return code are mapped to each other according to the preset association rules to form the first mapping relationship. The first return code, the second return code, the third return code, and the first mapping relationship are then stored in the database to complete the generation of the first mapping relationship.
[0095] S204, obtain a fourth return code; wherein the fourth return code is an identifier generated according to the processing result of the microservice unit on the target business.
[0096] Among them, the microservice unit generally has two processing results for the business client's request. One is that the microservice unit business processing is successful, and then the business service end is continued to be called. The other is that an error occurs at the microservice unit, that is, a business logic error occurs in the microservice unit and the next step cannot be performed. According to the processing result, the microservice unit will return a fourth return code to the business client to indicate the processing result of the microservice unit. Taking electronic payment as an example, if the microservice unit verifies the payment request sent by the business client, it can continue to the UnionPay system (that is, the business service end) and return "Authentication passed, payment in progress" to the business client. If an error occurs in the microservice unit, it can directly return the result of "Authentication failed" to the business client.
[0097] S205: Send a fourth return code to the microservice gateway. The fourth return code is used by the microservice gateway to read the second mapping relationship from the database and transcode the fourth return code according to the second mapping relationship to obtain a fifth return code.
[0098] In particular, the business client needs to identify the fourth return code returned by the microservice unit and also needs to transcode the fourth return code. The second mapping relationship stored in the database includes the mapping relationship between the fourth return code of the microservice system and the fifth return code of the business client. After the microservice unit sends the second return code to the microservice gateway, the microservice gateway can transcode the fourth return code according to the second mapping relationship and transcode the fourth return code into the fifth return code that the business client can recognize.
[0099] The second mapping relationship includes a mapping relationship between the fourth return code and the fifth return code.
[0100] Preferably, the method for generating the second mapping relationship includes: defining the fourth return code of the microservice unit and the fifth return code of the business client; establishing a second mapping relationship between the fourth return code and the fifth return code; and storing the fourth return code, the fifth return code and the second mapping relationship in the database.
[0101] To generate the second mapping relationship, the fourth and fifth return codes must first be defined. Specifically, the fourth and fifth return codes are defined based on the return code definition rules and methods of the microservice unit and the business client, respectively. After the definition is completed, the fourth and fifth return codes are mapped to each other according to the preset association rules to form the second mapping relationship. The fourth and fifth return codes and the second mapping relationship are then stored in the database, completing the generation of the second mapping relationship.
[0102] In this embodiment, when the microservice unit needs to transcode the first return code returned by the business server, it only needs to read the first mapping relationship in the database and then transcode the first return code according to the first mapping relationship. When the microservice gateway needs to transcode the second return code returned by the microservice unit, it also only needs to read the first mapping relationship in the database and then transcode the second return code according to the first mapping relationship.
[0103] By storing the first mapping relationship in a database for invocation, the transcoding rules for the first and second return codes are no longer configured in the microservice unit, nor are the transcoding rules for the second and third return codes configured in the microservice gateway. When the return code changes, only the first mapping relationship in the database needs to be updated to quickly update the return code. There is no need to issue a new program application version to replace the configuration information of the microservice unit and the microservice gateway. This reduces the cost of updating the return code and increases the speed of updating.
[0104] Similarly, when the microservice gateway needs to transcode the fourth return code returned by the microprocessor, it only needs to read the second mapping relationship in the database and transcode the fourth return code according to the second mapping relationship. When the return code changes, it only needs to update the second mapping relationship in the database to quickly update the return code.
[0105] Figure 3 For a flow chart of another business processing method based on microservice architecture provided in an embodiment of the present application, see Figure 3 In some embodiments, the business processing method based on the microservice architecture is applied to a microservice gateway, and the process includes the following steps:
[0106] S301, receiving a second return code returned by the microservice unit; wherein the second return code is obtained by the microservice unit reading a first mapping relationship from a database and transcoding the first return code returned by the business service end according to the first mapping relationship. The first return code is an identifier generated based on the processing result of the target business by the business service end. The business service end includes multiple business functions, and the target business corresponds to one of the business functions.
[0107] S302 : Read a first mapping relationship from a database, and transcode the second return code according to the first mapping relationship to obtain a third return code.
[0108] S303: Send the third return code to the business client.
[0109] The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
[0110] The transcoded third return code is sent to the business client. After the business client recognizes it, it outputs corresponding prompt information to prompt the business client of the processing result of the request sent.
[0111] S304: Receive a fourth return code sent by the microservice unit; wherein the fourth return code is an identifier generated according to the processing result of the microservice unit on the target business.
[0112] S305, reading a second mapping relationship from the database, and transcoding the fourth return code according to the second mapping relationship to obtain a fifth return code;
[0113] S306: Send the fifth return code to the business client.
[0114] Among them, the transcoded fifth return code will be sent to the business client. After the business client recognizes it, it will output corresponding prompt information to prompt the processing result of the request issued by the microservice unit.
[0115] The second mapping relationship includes a mapping relationship between the fourth return code and the fifth return code.
[0116] In this embodiment, it should be noted that Figure 3 In the process shown, the implementation principle and technical effect of each step can be found in the previous article about Figure 2 The relevant description will not be repeated here.
[0117] Figure 4 A flowchart of another business processing method based on a microservice architecture provided in an embodiment of the present application is provided in Figure 4 In some embodiments, the business processing method based on the microservice architecture is applied to a microservice system, which includes a business client, a microservice gateway, a microservice unit, a business service end, and a database. The process includes the following steps:
[0118] S401: The business service sends a first return code to the microservice unit.
[0119] S402: The microservice unit reads a first mapping relationship from a database.
[0120] S403: The microservice unit transcodes the first return code according to the first mapping relationship to obtain a second return code.
[0121] S404: The microservice unit sends a second return code to the microservice gateway.
[0122] S405: The microservice gateway reads the first mapping relationship from the database.
[0123] S406: The microservice gateway transcodes the second return code according to the first mapping relationship to obtain a third return code.
[0124] S407: The microservice gateway sends a third return code to the business client.
[0125] S408: The microservice unit sends a fourth return code to the microservice gateway.
[0126] S409: The microservice gateway reads the second mapping relationship from the database.
[0127] S410: The microservice gateway transcodes the fourth return code according to the second mapping relationship to obtain a fifth return code.
[0128] S411, the microservice gateway sends a fifth return code to the business client.
[0129] In this embodiment, it should be noted that Figure 4 In the process shown, the implementation principle and technical effect of each step can be found in the previous article about Figure 2 The relevant description will not be repeated here.
[0130] Figure 5 This is a schematic diagram of a business processing device of a microservice architecture provided by an embodiment of the present application. Figure 5 The business processing device of the microservice architecture is applied to the microservice unit, including various functional modules for implementing the aforementioned business processing method based on the microservice architecture. Any functional module can be implemented by software and / or hardware.
[0131] In some embodiments, the service processing device 500 of the microservice architecture includes a first receiving module 501, a first transcoding module 502, and a first sending module 503.
[0132] The first receiving module 501 is used to receive a first return code returned by the business server; wherein the first return code is an identifier generated according to the processing result of the target business by the business server, the business server includes multiple business functions, and the target business corresponds to one of the business functions;
[0133] The first transcoding module 502 is configured to read a first mapping relationship from a database, and transcode the first return code according to the first mapping relationship to obtain a second return code;
[0134] The first sending module 503 is used to send the second return code to the microservice gateway. The second return code is used by the microservice gateway to read the first mapping relationship from the database and transcode the second return code according to the first mapping relationship to obtain a third return code.
[0135] The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
[0136] In some embodiments, the apparatus further comprises:
[0137] The first receiving module 501 is used to obtain a fourth return code; wherein the fourth return code is an identifier generated according to the processing result of the microservice unit on the target business;
[0138] The first sending module 503 is used to send a fourth return code to the microservice gateway. The fourth return code is used by the microservice gateway to read the second mapping relationship from the database and transcode the fourth return code according to the second mapping relationship to obtain a fifth return code.
[0139] The second mapping relationship includes a mapping relationship between the fourth return code and the fifth return code.
[0140] The microservice architecture business processing device 500 provided in the embodiment of the present application is used to execute Figure 2 The technical solution provided by the embodiment of the business processing method based on the microservice architecture shown has similar implementation principles and technical effects as those in the embodiment of the aforementioned method and will not be repeated here.
[0141] Figure 6 This is a structural diagram of another microservice architecture business processing device provided by an embodiment of the present application, see Figure 6 The business processing device of the microservice architecture is applied to the microservice gateway, including various functional modules for implementing the aforementioned business processing method based on the microservice architecture. Any functional module can be implemented by software and / or hardware.
[0142] In some embodiments, the service processing device 600 of the microservice architecture includes a second receiving module 601, a second transcoding module 602, and a second sending module 603.
[0143] The second receiving module 601 is used to receive a second return code returned by the microservice unit; wherein the second return code is obtained by the microservice unit reading the first mapping relationship from the database and transcoding the first return code returned by the business service end according to the first mapping relationship. The first return code is an identifier generated by the business service end based on the processing result of the target business. The business service end includes multiple business functions, and the target business corresponds to one of the business functions.
[0144] The second transcoding module 602 is configured to read the first mapping relationship from the database, and transcode the second return code according to the first mapping relationship to obtain a third return code;
[0145] The second sending module 603 is used to send the third return code to the business client;
[0146] The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
[0147] In some embodiments, the apparatus further comprises:
[0148] The second receiving module 601 is used to receive the fourth return code sent by the microservice unit; wherein the fourth return code is an identifier generated according to the processing result of the microservice unit on the target business;
[0149] The second transcoding module 602 is configured to read a second mapping relationship from the database, and transcode the fourth return code according to the second mapping relationship to obtain a fifth return code;
[0150] The second sending module 603 is used to send the fifth return code to the business client;
[0151] The second mapping relationship includes a mapping relationship between the fourth return code and the fifth return code.
[0152] The microservice architecture business processing device 600 provided in the embodiment of the present application is used to execute Figure 3 The technical solution provided by the embodiment of the business processing method based on the microservice architecture shown has similar implementation principles and technical effects as those in the embodiment of the aforementioned method and will not be repeated here.
[0153] It should be noted that it should be understood that the division of the various modules of the above device is merely 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. Moreover, these modules can all be implemented in the form of software called by a processing element, or all in the form of hardware. Alternatively, some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the first transcoding module can be a separately established processing element, or it can be integrated into 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 by a processing element of the above device to perform the functions of the above first transcoding module. The implementation of other modules is similar. In addition, these modules can all or partly be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. During implementation, each step of the above method or each of the above modules can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0154] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, see Figure 7 , the electronic device 700 includes: a processor 701, and a memory 702 communicatively connected to the processor;
[0155] Memory 702 stores computer-executable instructions;
[0156] The processor 701 executes the computer-executable instructions stored in the memory to implement the technical solution of the aforementioned business processing method based on the microservice architecture.
[0157] In the above-mentioned electronic device, the memory 702 and the processor 701 are electrically connected directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines, such as through a bus connection. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus. The memory 702 stores computer-executable instructions for implementing the above-mentioned business processing method based on the microservice architecture, including at least one software function module that can be stored in the memory in the form of software or firmware. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory.
[0158] The memory 702 includes at least one type of readable storage medium, including but not limited to random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), and electrically erasable programmable read-only memory (EEPROM). The memory 702 is used to store programs, and the processor executes the programs after receiving execution instructions. Furthermore, the software programs and modules in the memory 702 may also include an operating system, which may include various software components and / or drivers for managing system tasks (e.g., memory management, storage device control, power management, etc.), and may communicate with various hardware or software components to provide an operating environment for other software components.
[0159] The processor 701 can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor 701 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), etc. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor, or the processor can also be any conventional processor, etc.
[0160] The electronic device 700 is used to execute the technical solution provided by the aforementioned business processing method embodiment based on microservice architecture. Its implementation principle and technical effects are similar to those in the aforementioned method embodiment and will not be repeated here.
[0161] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions. When a processor executes the computer-executable instructions, the technical solution of the business processing method based on the microservice architecture as described above is implemented.
[0162] The computer-readable storage medium may be implemented by any type of volatile or non-volatile memory 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 storage, flash memory, magnetic disk, or optical disk. The computer-readable storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0163] An exemplary readable storage medium is coupled to the processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be an integral part of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the readable storage medium can also exist as discrete components in the control device of the microservice unit or microservice gateway.
[0164] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the technical solution of the aforementioned business processing method based on a microservice architecture.
[0165] In the above embodiments, those skilled in the art will appreciate that the above-mentioned various method embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, they can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless network, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated therein. Available media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVDs), or semiconductor media (eg, solid-state drives (SSDs)).
[0166] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0167] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A business processing method based on microservice architecture, applied to a microservice unit, characterized in that: include: receiving a first return code returned by the business service end; wherein the first return code is an identifier generated according to a processing result of the target business by the business service end, the business service end includes multiple business functions, and the target business corresponds to one of the business functions; Reading a first mapping relationship from a database, and transcoding the first return code according to the first mapping relationship to obtain a second return code; Sending the second return code to the microservice gateway, where the second return code is used by the microservice gateway to read the first mapping relationship from the database, and transcoding the second return code according to the first mapping relationship to obtain a third return code; The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
2. The method according to claim 1, characterized in that Also includes: Obtaining a fourth return code; wherein the fourth return code is an identifier generated according to the processing result of the target business by the microservice unit; Sending the fourth return code to the microservice gateway, where the fourth return code is used by the microservice gateway to read the second mapping relationship from the database, and transcoding the fourth return code according to the second mapping relationship to obtain a fifth return code; The second mapping relationship includes a mapping relationship between the fourth return code and the fifth return code.
3. A business processing method based on microservice architecture, applied to a microservice gateway, characterized in that: include: Receive a second return code returned by the microservice unit; wherein the second return code is obtained by the microservice unit reading a first mapping relationship from a database and transcoding a first return code returned by the business service end according to the first mapping relationship; the first return code is an identifier generated based on a processing result of the target business by the business service end; the business service end includes multiple business functions, and the target business corresponds to one of the business functions; Reading the first mapping relationship from the database, and transcoding the second return code according to the first mapping relationship to obtain a third return code; Sending the third return code to the business client; The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
4. The method according to claim 3, characterized in that Also includes: Receive a fourth return code sent by the microservice unit; wherein the fourth return code is an identifier generated according to the processing result of the target business by the microservice unit; Reading a second mapping relationship from a database, and transcoding the fourth return code according to the second mapping relationship to obtain a fifth return code; Sending the fifth return code to the business client; The second mapping relationship includes a mapping relationship between the fourth return code and the fifth return code.
5. A business processing device of a microservice architecture, applied to a microservice unit, characterized in that: include: a first receiving module, configured to receive a first return code returned by the business server; wherein the first return code is an identifier generated according to a processing result of the target business by the business server, the business server including multiple business functions, and the target business corresponding to one of the business functions; a first transcoding module, configured to read a first mapping relationship from a database, and transcode the first return code according to the first mapping relationship to obtain a second return code; A first sending module is configured to send the second return code to the microservice gateway, where the second return code is used by the microservice gateway to read the first mapping relationship from the database and transcode the second return code according to the first mapping relationship to obtain a third return code; The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
6. A business processing device of a microservice architecture, applied to a microservice gateway, characterized in that: include: a second receiving module, configured to receive a second return code returned by the microservice unit; wherein the second return code is obtained by the microservice unit reading a first mapping relationship from a database and transcoding a first return code returned by the business service end according to the first mapping relationship; the first return code is an identifier generated based on a processing result of the target business by the business service end; the business service end includes multiple business functions, and the target business corresponds to one of the business functions; a second transcoding module, configured to read the first mapping relationship from the database, and transcode the second return code according to the first mapping relationship to obtain a third return code; A second sending module, configured to send the third return code to the service client; The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
7. A microservice system, characterized in that: The microservice system includes a business client, a microservice gateway, a microservice unit, a business service end and a database; wherein: The business service end is used to send a first return code to the microservice unit; wherein the first return code is an identifier generated according to the processing result of the target business by the business service end, the business service end includes multiple business functions, and the target business corresponds to one of the business functions; The microservice unit is configured to receive the first return code returned by the business service end, read the first mapping relationship from the database, and transcode the first return code according to the first mapping relationship to obtain a second return code; The microservice gateway is configured to receive the second return code returned by the microservice unit, read the first mapping relationship from a database, and transcode the second return code according to the first mapping relationship to obtain a third return code; The business client is used to receive a third return code returned by the microservice gateway; The first mapping relationship includes a mapping relationship among the first return code, the second return code, and the third return code.
8. The system according to claim 7, characterized in that: The database stores the first mapping relationship in a database cache based on a database cache mechanism.
9. An electronic device, 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 4.
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 4 when executed by a processor.
Citation Information
Patent Citations
Software system error code management method and device, electronic equipment and storage medium
CN113485939A
Service system management method and device
CN114546475A