A method, device, equipment and medium for automatic compensation of transaction process data

In the distributed microservice framework, using the cache database and preset frequency time scanning mechanism, the data loss problem of transaction process caused by the downtime of synchronous process microservices is solved, and the automatic compensation and persistence of data is realized, reducing maintenance costs and improving customer experience.

CN114862582BActive Publication Date: 2025-04-15BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210544786.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-19
Publication Date
2025-04-15
Estimated Expiration
2042-05-19

AI Technical Summary

Technical Problem

Under the distributed microservice framework, when synchronous process microservices fail, transaction process data cannot be persisted, resulting in data loss and high maintenance costs.

Method used

When a transaction request is detected, the transaction process data generated by the microservice's call process is stored in the cache database, and the data is persisted to the target database when the microservice call is completed or downtime. At the same time, scan the cache database according to the preset frequency time to ensure that the data can still be persisted when the microservice goes down.

Benefits of technology

It realizes that even if the microservice application is down, transaction process data can still be persisted to the database, avoiding manual repair of exceptions, saving human resources, reducing maintenance costs, and improving customer experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114862582B_ABST
    Figure CN114862582B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, equipment and medium for automatic compensation of transaction process data, which can be applied to distributed fields and financial fields. The method includes: when a transaction request is detected, the microservice corresponding to the transaction request is called, and the transaction process data generated by the calling process of the microservice is stored in the cache database, so that when the microservice application is not down and the microservice call is completed, the transaction process data in the cache database is persisted to the target database, and the transaction process data in the cache database is deleted, and the cache database is scanned at a preset frequency time. If the transaction process data is scanned, the transaction process data is persisted to the target database. The frequency time of the present application is greater than the calling time of the microservice. Even if the microservice application is down, the transaction process data can still be persisted to the database, which provides a good customer experience. When the microservice application is down, there is no need to manually repair the anomaly, which saves human resources and reduces maintenance costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a method, device, equipment and medium for automatic compensation of transaction process data. Background Art

[0002] In a system under a distributed microservice framework, the entire process from transaction entry to completion of transaction activities requires calling at least one microservice under a synchronous process and at least one microservice under an asynchronous process. The microservices under the synchronous process are used to complete transaction activities and persist the transaction process data generated by the microservice call process to the database. The microservices under the asynchronous process are used to perform subsequent processing based on the transaction process data in the database.

[0003] At present, when a new transaction enters the system and starts the synchronization process, if a microservice call under the synchronization process is completed, the orchestration and scheduling node corresponding to the microservice suddenly crashes, the transaction process data generated by the microservice call process will not be persisted in the database, which will lead to the loss of transaction process data generated by the microservice call process. Manual verification and script running are required to repair the transaction, which consumes a lot of human resources and has high maintenance costs. In addition, since the microservice under the synchronization process has been completed, the orchestration and scheduling node will not return an exception to the orchestration node, resulting in a delay in the discovery of abnormal transactions and a poor customer experience. Summary of the invention

[0004] In view of this, the present application provides a transaction process data automatic compensation method, device, equipment and medium to solve the above technical problems, and its technical solution is as follows:

[0005] A transaction process data automatic compensation method, comprising:

[0006] When a transaction request is detected, the microservice corresponding to the transaction request is called, and the transaction process data generated by the calling process of the microservice is stored in the cache database, so that when the microservice application corresponding to the microservice is not down and the microservice call is completed, the transaction process data in the cache database is persisted to the target database, and the transaction process data in the cache database is deleted, wherein the microservice is a microservice under the synchronization process corresponding to the transaction request;

[0007] The cache database is scanned at a preset frequency time, and if the transaction process data is scanned, the transaction process data is persisted in the target database, wherein the frequency time is greater than the calling time of the microservice.

[0008] Optionally, before calling the microservice corresponding to the transaction request, the method further includes:

[0009] When the transaction request is detected, the unique identification information of the transaction request is stored in the cache database.

[0010] Optionally, storing the transaction process data generated by the calling process of the microservice in a cache database includes:

[0011] The unique identification information of the transaction request in the cache database is used as the key, and the transaction process data generated by the calling process of the microservice is used as the value corresponding to the key, and the transaction process data generated by the calling process of the microservice is stored in the cache database in the form of a key-value pair.

[0012] Optionally, persisting the transaction process data to the target database includes:

[0013] Determining whether there is target process data corresponding to the transaction process data in the target database, wherein the target process data has the same transaction activity serial number as the transaction process data;

[0014] If so, determine whether the generation time of the transaction process data is later than the generation time of the target process data, and if the generation time of the transaction process data is later than the generation time of the target process data, delete the target process data and persist the transaction process data in the target database;

[0015] If not, the transaction process data is persisted in the target database.

[0016] Optionally, after persisting the transaction process data in the target database, the method further includes:

[0017] Determine whether the distributed lock added to the microservice has been unlocked;

[0018] If not, the distributed lock added to the microservice is unlocked.

[0019] Optionally, the transaction process data includes transaction activity status and transaction context data, the transaction activity status is used to characterize the state of the microservice during the calling process, and the transaction context data refers to transaction-related data of the microservice during the calling process.

[0020] A transaction process data automatic compensation device, comprising:

[0021] A data buffer storage module is used to call the microservice corresponding to the transaction request when a transaction request is detected, and store the transaction process data generated by the calling process of the microservice in a cache database, so that when the microservice application corresponding to the microservice is not down and the microservice call is completed, the transaction process data in the cache database is persisted to the target database, and the transaction process data in the cache database is deleted, wherein the microservice is a microservice under the synchronization process corresponding to the transaction request;

[0022] The data persistence storage module is used to scan the cache database according to a preset frequency time. If the transaction process data is scanned, the transaction process data is persisted in the target database, wherein the frequency time is greater than the calling time of the microservice.

[0023] Optionally, also include:

[0024] The identification cache storage module is used to store the unique identification information of the transaction request in the cache database when the transaction request is detected before the microservice corresponding to the transaction request is called.

[0025] A transaction process data automatic compensation device, comprising a memory and a processor;

[0026] The memory is used to store programs;

[0027] The processor is used to execute the program to implement each step of the automatic compensation method for transaction process data as described in any one of the above items.

[0028] A readable storage medium stores a computer program thereon, and when the computer program is executed by a processor, the computer program implements the various steps of the automatic compensation method for transaction process data as described in any one of the above items.

[0029] Through the above technical solutions, it can be known that the automatic compensation method for transaction process data provided by the present application, when a transaction request is detected, calls the microservice corresponding to the transaction request, and stores the transaction process data generated by the calling process of the microservice in the cache database, so that the microservice application corresponding to the microservice does not crash, and when the microservice call is completed, the transaction process data in the cache database is persisted to the target database, and the transaction process data in the cache database is deleted, and the cache database is scanned according to the preset frequency time. If the transaction process data is scanned, the transaction process data is persisted to the target database. The frequency time in the present application is greater than the calling time of the microservice. If the transaction process data exists in the cache database, it means that the microservice application has crashed. At this time, the transaction process data can be persisted to the database, so that even if the microservice application crashes, the transaction process data can still be persisted to the database, and then the subsequent asynchronous process can be completed normally, the customer experience is better, and there is no need to manually repair the abnormality when the microservice application crashes, which saves human resources and reduces maintenance costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0031] Figure 1 A flowchart of a transaction process data automatic compensation method provided in an embodiment of the present application;

[0032] Figure 2 A schematic diagram of the overall process of a transaction activity provided in an embodiment of the present application;

[0033] Figure 3 A schematic diagram of the structure of a transaction process data automatic compensation device provided in an embodiment of the present application;

[0034] Figure 4 A hardware structure block diagram of a transaction process data automatic compensation device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0036] In view of the problems existing in the above-mentioned ideas, the inventor of this case conducted in-depth research and finally proposed a method for automatic compensation of transaction process data. The method for automatic compensation of transaction process data can be applied to an orchestration and scheduling node, which contains microservice applications corresponding to the microservices that can be called.

[0037] It should be noted that the transaction process data automatic compensation method, device, system and medium provided by the present invention can be used in the distributed field and the financial field. The above is only an example and does not limit the application field of the transaction process data automatic compensation method, device, equipment and medium provided by the present invention.

[0038] Next, the transaction process data automatic compensation method provided by this application is introduced in detail through the following embodiments.

[0039] See also Figure 1 , shows a schematic diagram of a process flow of a method for automatic compensation of transaction process data provided by an embodiment of the present application, and the method for automatic compensation of transaction process data may include:

[0040] Step S101: When a transaction request is detected, the microservice corresponding to the transaction request is called, and the transaction process data generated by the microservice calling process is stored in the cache database, so that when the microservice application corresponding to the microservice is not down and the microservice call is completed, the transaction process data in the cache database is persisted to the target database, and the transaction process data in the cache database is deleted.

[0041] Among them, the microservice is a microservice under the synchronization process corresponding to the transaction request.

[0042] In this step, the transaction process corresponding to the transaction request initiated by the user usually includes a synchronous process and an asynchronous process. The synchronous process is composed of several microservices. For example, the process of purchasing clothing A is composed of at least a payment microservice (a microservice under the synchronous process) and an inventory deduction microservice (a microservice under the synchronous process).

[0043] When a transaction request is detected, the microservice under the synchronization process corresponding to the transaction request can be called. Transaction process data will be generated in the process of microservice calling. This step first stores the transaction process data generated by the microservice calling process in the cache database (i.e., redis cache). When the microservice call is completed and the microservice application is not down, the transaction process data in the cache database will be persisted to the target database.

[0044] In order to avoid periodic hangs and restore transaction process data, the transaction process data in the cache database can be deleted after persisting the transaction process data in the cache database to the target database.

[0045] Optionally, the transaction process data in this embodiment includes transaction activity status and transaction context data, wherein the transaction activity status is used to characterize the state of the microservice during the call process, and the transaction context data refers to the transaction-related data of the microservice during the call process. For example, for a payment microservice, the transaction activity status may include initialization status, calling status, payment success, payment failure, etc., and the transaction context data includes payment amount, payment method, etc.

[0046] Step S102: Scan the cache database at a preset frequency and time. If transaction process data is found, persist the transaction process data in the target database.

[0047] Among them, the frequency time is greater than the call time of the microservice.

[0048] It is understandable that when the microservice application corresponding to the called microservice goes down, the transaction process data in the cache database can no longer be persisted to the target database. At this time, you can set a springboot scheduled task to scan the cache database at a preset frequency.

[0049] Since the frequency time is greater than the calling time of the microservice, if the microservice application is not down, the transaction process data in the cache database can be persisted to the target database before the frequency time arrives, and the transaction process data in the cache database can be deleted. When the frequency time is reached, the cache database will be scanned again, and the transaction process data will not be scanned. On the contrary, if the microservice application is down, the transaction process data in the cache database cannot be persisted to the target database, and the transaction process data will be scanned when the cache database is scanned. At this time, the transaction process data can be persisted to the target database to avoid the loss of transaction process data.

[0050] It should be noted that the frequency time in this step can be determined according to the actual situation, but it needs to be greater than the call time of the microservice to ensure that the transaction process data can be persisted to the target database when the microservice application is not down. Optionally, the frequency time can be set to 5 minutes.

[0051] Optionally, after persisting the transaction process data to the target database in this step, the transaction process data in the cache database may also be deleted.

[0052] Optionally, in this step, the abnormal transaction process data generated due to the downtime of the microservice application can be restored and persisted to the target database through the timing component. Here, the abnormal transaction process data refers to the transaction process data that cannot be persisted to the target database due to the downtime of the microservice application.

[0053] The automatic compensation method for transaction process data provided in the present application calls the microservice corresponding to the transaction request when a transaction request is detected, and stores the transaction process data generated by the calling process of the microservice in the cache database, so that the microservice application corresponding to the microservice does not crash. When the microservice call is completed, the transaction process data in the cache database is persisted to the target database, and the transaction process data in the cache database is deleted. The cache database is scanned at a preset frequency time. If the transaction process data is scanned, the transaction process data is persisted to the target database. The frequency time in the present application is greater than the calling time of the microservice. If the transaction process data is scanned in the cache database, it means that the microservice application has crashed. At this time, the transaction process data can be persisted to the database, so that even if the microservice application crashes, the transaction process data can still be persisted to the database, and then the subsequent asynchronous process can be completed normally, the customer experience is better, and there is no need to manually repair the abnormality when the microservice application crashes, which saves human resources and reduces maintenance costs.

[0054] In an optional embodiment, considering that there may be multiple transaction requests at the same time, in order to make the multiple transaction requests correspond one-to-one with the transaction process data corresponding to the transaction requests, the unique identification information of the transaction request can be stored in the cache database when the transaction request is detected before calling the microservice corresponding to the transaction request.

[0055] Optionally, the unique identification information of the transaction activity may be stored in a cache database in a sorted queue (zset). Optionally, the unique identification information may specifically be a unique ID (identification number) or a transaction activity serial number.

[0056] On this basis, the process of "storing the transaction process data generated by the microservice calling process in the cache database" in the aforementioned step S101 may include: using the unique identification information of the transaction request in the cache database as the key, and using the transaction process data generated by the microservice calling process as the value corresponding to the key, and storing the transaction process data generated by the microservice calling process in the cache database in the form of key-value pairs.

[0057] Specifically, this step can store the transaction process data in the cache database in the form of a hash table (i.e., a key-value pair), wherein the unique identification information of the transaction request in the cache database is used as the key, and the transaction process data generated by the microservice calling process is used as the value corresponding to the key.

[0058] Continuing the above description, the aforementioned step S102, when "scanning the cache database at a preset frequency time", can specifically be scanning the unique identification information in the redis ordered queue buffer. If the unique identification information is scanned, the transaction process data corresponding to the scanned unique identification information is scanned out from the hash table.

[0059] In summary, through the processing flow of this embodiment, the transaction request and the transaction process data can be matched one by one, which helps to improve the efficiency of subsequent transaction processing.

[0060] Considering that in the transaction process processing based on distributed implementation, the same microservice can be called by multiple orchestration and scheduling nodes, the transaction process data generated by multiple orchestration and scheduling nodes when calling the microservice may be persisted to the target database. At this time, duplicate transaction process data will appear in the target database. In order to save database space, in step S102 "persisting the transaction process data to the target database", the order of generation time of the transaction process data and the target process data already stored in the target database can be first determined to retain the latest transaction process data.

[0061] Based on this, the process of step S102 "persisting the transaction process data in the target database" may include:

[0062] Step S1021, determine whether there is target process data corresponding to the transaction process data in the target database.

[0063] Among them, the transaction activity serial number corresponding to the target process data and the transaction process data is the same.

[0064] Optionally, the target database may store transaction activity serial numbers corresponding to the transaction process data. When different distributed orchestration and scheduling nodes make microservice calls for a transaction request, the transaction activity serial numbers are the same. This step can determine whether there is target process data corresponding to the transaction process data in the target database by judging the transaction activity serial number. Here, the target process data refers to the transaction process data generated by other orchestration and scheduling nodes in the process of calling microservices.

[0065] Step S1022: If yes, determine whether the generation time of the transaction process data is later than the generation time of the target process data. If the generation time of the transaction process data is later than the generation time of the target process data, delete the target process data and persist the transaction process data in the target database.

[0066] In this step, if it is determined that there is target process data corresponding to the transaction process data in the target database, it is necessary to compare whether the generation time of the transaction process data is later than the generation time of the target process data. If so, the target process data in the target database will be deleted and the transaction process data will be persisted to the target database. If not, no processing will be performed.

[0067] Here, there are many reasons why the generation time of the transaction process data is later than the generation time of the target process data. For example, the network environment of the current orchestration and scheduling node may be poor, resulting in a lot of time spent scanning the cache database, so that other orchestration and scheduling nodes may have persisted the target process data to the target database during persistence.

[0068] Step S1023: If not, persist the transaction process data to the target database.

[0069] In this step, there may be a situation where there is no target process data corresponding to the transaction process data in the target database. In this case, the transaction process data can be directly persisted in the target database.

[0070] Through the processing of this embodiment, it is possible to prevent duplicate records from being stored in the target database, thereby improving the utilization rate of the target database space.

[0071] In summary, see Figure 2 As shown, a schematic diagram of the overall process of a transaction activity provided by an embodiment of the present application is shown.

[0072] When a transaction request is received (transaction entry starts), microservice 1 and microservice 2 under the synchronous process can be called, and when the calls of microservice 1 and microservice 2 are completed, the transaction process data (such as transaction activity status and transaction context) are temporarily stored in redis (i.e., cache database), and the transaction process data in redis is scanned regularly. When the transaction process data is scanned, the scanned transaction process data is restored and persisted to the target database. In addition, the transaction process data in the target database that needs to call the asynchronous service is scanned regularly to continue the asynchronous process.

[0073] It should be noted that Figure 2 The synchronization process includes microservice 1 and microservice 2 for illustrative purposes only and is not intended to limit the present application.

[0074] In an optional embodiment, taking into account the situation that in the event of a microservice application crash, the distributed lock added to the microservice may not be unlocked after the synchronization process is completed due to the microservice application crash. In order to avoid the situation where the asynchronous process cannot be executed normally if it is not unlocked, this embodiment can determine whether the distributed lock added to the microservice under the synchronization process has been unlocked after persisting the transaction process data to the target database. If not, the distributed lock added to the microservice is unlocked.

[0075] In this embodiment, even if the microservice application crashes, the distributed lock added to the microservice can still be released, so that the subsequent asynchronous process can proceed normally, thus completing the entire transaction process and improving the user experience.

[0076] An embodiment of the present application also provides an automatic compensation device for transaction process data. The automatic compensation device for transaction process data provided by the embodiment of the present application is described below. The automatic compensation device for transaction process data described below and the automatic compensation method for transaction process data described above can be referenced to each other.

[0077] See also Figure 3 , shows a schematic diagram of the structure of the transaction process data automatic compensation device provided by the embodiment of the present application, such as Figure 3 As shown, the transaction process data automatic compensation device may include: a data buffer storage module 301 and a data persistent storage module 302.

[0078] The data buffer storage module 301 is used to call the microservice corresponding to the transaction request when a transaction request is detected, and store the transaction process data generated by the calling process of the microservice in the cache database, so that when the microservice application corresponding to the microservice is not down and the microservice call is completed, the transaction process data in the cache database is persisted to the target database and the transaction process data in the cache database is deleted, wherein the microservice is a microservice under the synchronization process corresponding to the transaction request.

[0079] The data persistence storage module 302 is used to scan the cache database according to a preset frequency time. If the transaction process data is scanned, the transaction process data is persisted in the target database, wherein the frequency time is greater than the calling time of the microservice.

[0080] The automatic compensation device for transaction process data provided by the present application calls the microservice corresponding to the transaction request when a transaction request is detected, and stores the transaction process data generated by the calling process of the microservice in the cache database, so that the microservice application corresponding to the microservice does not crash. When the microservice call is completed, the transaction process data in the cache database is persisted to the target database, and the transaction process data in the cache database is deleted. The cache database is scanned at a preset frequency time. If the transaction process data is scanned, the transaction process data is persisted to the target database. The frequency time in the present application is greater than the calling time of the microservice. If the transaction process data is scanned in the cache database, it means that the microservice application has crashed. At this time, the transaction process data can be persisted to the database, so that even if the microservice application crashes, the transaction process data can still be persisted to the database, and then the subsequent asynchronous process can be completed normally, the customer experience is better, and there is no need to manually repair the abnormality when the microservice application crashes, which saves human resources and reduces maintenance costs.

[0081] In a possible implementation, the transaction process data automatic compensation device provided in the present application may also include: an identification cache storage module.

[0082] The identification cache storage module is used to store the unique identification information of the transaction request in the cache database when the transaction request is detected before the microservice corresponding to the transaction request is called.

[0083] In a possible implementation, when the data buffer storage module 301 stores the transaction process data generated by the calling process of the microservice in the cache database, it can be specifically used to use the unique identification information of the transaction request in the cache database as a key, and the transaction process data generated by the calling process of the microservice as the value corresponding to the key, and store the transaction process data generated by the calling process of the microservice in the cache database in the form of a key-value pair.

[0084] In a possible implementation, when persisting the transaction process data in the target database, the data persistence storage module 302 can be specifically used to determine whether there is target process data corresponding to the transaction process data in the target database; if so, determine whether the generation time of the transaction process data is later than the generation time of the target process data; and if the generation time of the transaction process data is later than the generation time of the target process data, delete the target process data and persist the transaction process data in the target database; if not, persist the transaction process data in the target database; wherein the target process data is the same as the transaction activity serial number corresponding to the transaction process data.

[0085] In a possible implementation, the transaction process data automatic compensation device provided in the present application may also include: a distributed lock unlocking module.

[0086] The distributed lock unlocking module is used to determine whether the distributed lock added to the microservice has been unlocked. If not, the distributed lock added to the microservice is unlocked.

[0087] The embodiment of the present application also provides a transaction process data automatic compensation device. Optionally, Figure 4 The hardware structure diagram of the transaction process data automatic compensation device is shown. Figure 4 , the hardware structure of the transaction process data automatic compensation device may include: at least one processor 401, at least one communication interface 402, at least one memory 403 and at least one communication bus 404;

[0088] In the embodiment of the present application, the number of the processor 401, the communication interface 402, the memory 403, and the communication bus 404 is at least one, and the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404;

[0089] The processor 401 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention;

[0090] The memory 403 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;

[0091] The memory 403 stores a program, and the processor 401 can call the program stored in the memory 403, and the program is used to:

[0092] When a transaction request is detected, the microservice corresponding to the transaction request is called, and the transaction process data generated by the calling process of the microservice is stored in the cache database, so that when the microservice application corresponding to the microservice is not down and the microservice call is completed, the transaction process data in the cache database is persisted to the target database, and the transaction process data in the cache database is deleted, wherein the microservice is a microservice under the synchronization process corresponding to the transaction request;

[0093] The cache database is scanned at a preset frequency time, and if the transaction process data is scanned, the transaction process data is persisted in the target database, wherein the frequency time is greater than the calling time of the microservice.

[0094] Optionally, the detailed functions and extended functions of the program may refer to the above description.

[0095] An embodiment of the present application further provides a readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the above method is implemented.

[0096] Optionally, the detailed functions and extended functions of the program may refer to the above description.

[0097] Finally, it should be noted that, in this article, relational terms such as and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprises a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0098] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0099] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for automatic compensation of transaction process data, characterized in that: include: When a transaction request is detected, the microservice corresponding to the transaction request is called, and the transaction process data generated by the calling process of the microservice is stored in the cache database, so that when the microservice application corresponding to the microservice is not down and the microservice call is completed, the transaction process data in the cache database is persisted to the target database, and the transaction process data in the cache database is deleted, wherein the microservice is a microservice under the synchronization process corresponding to the transaction request; The cache database is scanned at a preset frequency time, and if the transaction process data is scanned, the transaction process data is persisted in the target database, wherein the frequency time is greater than the calling time of the microservice.

2. The automatic transaction process data compensation method according to claim 1, characterized in that: Before calling the microservice corresponding to the transaction request, the method further includes: When the transaction request is detected, the unique identification information of the transaction request is stored in the cache database.

3. The automatic transaction process data compensation method according to claim 2, characterized in that: The storing of the transaction process data generated by the calling process of the microservice in the cache database includes: The unique identification information of the transaction request in the cache database is used as the key, and the transaction process data generated by the calling process of the microservice is used as the value corresponding to the key, and the transaction process data generated by the calling process of the microservice is stored in the cache database in the form of a key-value pair.

4. The automatic transaction process data compensation method according to claim 1, characterized in that: The persisting the transaction process data to the target database includes: Determining whether there is target process data corresponding to the transaction process data in the target database, wherein the target process data has the same transaction activity serial number as the transaction process data; If so, determine whether the generation time of the transaction process data is later than the generation time of the target process data, and if the generation time of the transaction process data is later than the generation time of the target process data, delete the target process data and persist the transaction process data in the target database; If not, the transaction process data is persisted in the target database.

5. The automatic transaction process data compensation method according to claim 1, characterized in that: After persisting the transaction process data in the target database, the method further includes: Determine whether the distributed lock added to the microservice has been unlocked; If not, the distributed lock added to the microservice is unlocked.

6. The automatic transaction process data compensation method according to claim 1, characterized in that: The transaction process data includes transaction activity status and transaction context data. The transaction activity status is used to characterize the status of the microservice during the calling process, and the transaction context data refers to transaction-related data of the microservice during the calling process.

7. A transaction process data automatic compensation device, characterized in that: include: A data buffer storage module is used to call the microservice corresponding to the transaction request when a transaction request is detected, and store the transaction process data generated by the calling process of the microservice in a cache database, so that when the microservice application corresponding to the microservice is not down and the microservice call is completed, the transaction process data in the cache database is persisted to the target database, and the transaction process data in the cache database is deleted, wherein the microservice is a microservice under the synchronization process corresponding to the transaction request; The data persistence storage module is used to scan the cache database according to a preset frequency time. If the transaction process data is scanned, the transaction process data is persisted in the target database, wherein the frequency time is greater than the calling time of the microservice.

8. The transaction process data automatic compensation device according to claim 7, characterized in that: Also includes: The identification cache storage module is used to store the unique identification information of the transaction request in the cache database when the transaction request is detected before the microservice corresponding to the transaction request is called.

9. A transaction process data automatic compensation device, characterized in that: including memory and processor; The memory is used to store programs; The processor is used to execute the program to implement the various steps of the transaction process data automatic compensation method as described in any one of claims 1 to 6.

10. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the method for automatic compensation of transaction process data as described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method for synchronizing data in heterogeneous database

    CN111858597A

  • Serial number configuration method and device, equipment and storage medium

    CN112667685A