Transaction processing method, system and device and storage medium

By generating a unique flow number for process transactions under the microservice architecture and verifying the preconditions and business data integrity, the problems of process transaction information integrity and tamper-proof difficulty are solved, and the security and consistency of transactions are achieved. Simplified management process.

CN119295073APending Publication Date: 2025-01-10BANK OF NINGBO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411416972.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-11
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

Under the microservice architecture, the information integrity and tamper-proof difficulty of process transactions have increased, and the existing technology lacks unified standards and processes, resulting in a variety of anti-step and tamper-proof implementation methods and varying quality, making it difficult to manage and evaluate uniformly.

Method used

By generating a unique flow number at the beginning of the transaction and storing it to a single-point storage system, the preconditions of the transaction steps and the integrity of the business data are verified, the order and integrity of the transaction are ensured, the jump and tampering are prevented, and a unified transaction processing is provided Methods and systems.

Benefits of technology

It improves the security and integrity of transaction information, reduces the workload of R&D personnel in anti-step and anti-tampering functions, simplifies transaction process management, and ensures the security and consistency of transaction information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119295073A_ABST
    Figure CN119295073A_ABST
Patent Text Reader

Abstract

The invention discloses a transaction processing method, system and device and a storage medium. A business transaction process is abstracted into three stages: transaction start, transaction process and transaction end. Each link of the transaction is planned at the beginning of the transaction, and information is transmitted by using a single point when the transaction is carried out to the next link. Before each transaction step is executed, precondition verification and business data tampering verification are automatically carried out. The mechanism ensures that only transaction steps which meet conditions and are not tampered with data can be executed, and malicious attacks and misoperation are effectively prevented. Therefore, the workload of research and development personnel in realizing anti-leapfrogging and anti-tampering functions is reduced, and the security and integrity of transaction information are ensured. Therefore, the security of the system is improved, and the management of the transaction process is simplified, so that research and development personnel can concentrate on the development of business logic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a transaction processing method, system, device and storage medium. Background Art

[0002] As enterprise architectures transform from traditional monolithic applications to microservices architectures, more and more applications and services are being split into independent, small services. This shift brings advantages such as better scalability, greater flexibility, and faster iteration. However, it also introduces some new challenges, especially when dealing with process-based transactions. Process-based transactions typically involve multiple steps that have dependencies between them and require execution in a certain order. In monolithic applications, this dependency is relatively easy to manage and control because all logic is executed in the same process. However, under a microservices architecture, the transaction process may span multiple different services, which increases the difficulty of maintaining the integrity of transaction information and preventing information tampering.

[0003] In past practices, the anti-skipping and anti-tampering functions were often implemented by individual R&D personnel, which resulted in various implementation methods and inconsistent quality. Some transactions may not have been fully security-verified, and there is a risk of tampering or skipping. In addition, since there is no unified standard and process to guide the implementation of anti-tampering and anti-skipping, the security implementation methods of different transactions may vary greatly, making it difficult to conduct unified evaluation and management. Summary of the invention

[0004] Based on the above problems, the present application provides a transaction processing method, system, device and storage medium.

[0005] Embodiments of the present application A first aspect of an embodiment of the present application discloses a transaction processing method, including:

[0006] Initializing the target transaction, and storing the initialization data obtained by initialization and the serial number of the target transaction in a single-point storage system;

[0007] Before executing a transaction step, check whether the current transaction step meets the preconditions, and check whether the business data of the current transaction step has been tampered with;

[0008] When the current transaction step passes the verification, executing the current transaction step based on the initialization data;

[0009] When all transaction steps of the target transaction are completed, the data in the single-point storage system is cleared.

[0010] In a possible implementation, when the current transaction step passes verification, after executing the current transaction step based on the initialization data, the method further includes:

[0011] Verify the business data input and output when executing the current transaction step.

[0012] In a possible implementation, when the current transaction step passes verification, after executing the current transaction step based on the initialization data, the method further includes:

[0013] Update the transaction status information of the current transaction step to the completed status.

[0014] In a possible implementation, before executing the transaction step, after checking whether the current transaction step meets the precondition and checking whether the business data of the current transaction step has been tampered with, the method further includes:

[0015] Based on the execution order of the transaction steps of the target transaction, check whether there is any step skipping in the current transaction step.

[0016] In a possible implementation, when all transaction steps of the target transaction are completed, before clearing the data in the single-point storage system, the method further includes:

[0017] Verify whether all transaction steps of the target transaction have been completed, and verify whether the business data corresponding to the target transaction meets the integrity and consistency requirements;

[0018] When all transaction steps of the target transaction are completed, clearing the data in the single-point storage system includes:

[0019] When all transaction steps of the target transaction have been completed and the business data corresponding to the target transaction meets the integrity and consistency requirements, the data in the single-point storage system is cleared.

[0020] In a possible implementation, the initialization data includes group information and a transaction link, and the group information is used to indicate that the to-be-executed group is adjusted based on the transaction link during the transaction process, so that the transaction steps corresponding to the to-be-executed group are sequentially executed based on the target identifier.

[0021] In a possible implementation, when the current transaction step passes verification, after executing the current transaction step based on the initialization data, the method further includes:

[0022] Based on the execution result of the current transaction step, determine the next transaction step to be executed.

[0023] A second aspect of an embodiment of the present application discloses a transaction processing system, including:

[0024] A storage unit, used to initialize the target transaction and store the initialization data obtained by initialization and the serial number of the target transaction in a single-point storage system;

[0025] A verification unit, used to verify whether the current transaction step meets the preconditions before executing the transaction step, and to verify whether the business data of the current transaction step has been tampered with;

[0026] An execution unit, configured to execute the current transaction step based on the initialization data when the current transaction step passes verification;

[0027] The clearing unit is used to clear the data in the single-point storage system when all transaction steps of the target transaction are completed.

[0028] The third aspect of an embodiment of the present application discloses an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the transaction processing method as described in the first aspect above is implemented.

[0029] The fourth aspect of an embodiment of the present application discloses a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device executes the transaction processing method as described in the first aspect above.

[0030] Compared with the prior art, this application has the following beneficial effects:

[0031] By generating a unique serial number at the beginning of a transaction and storing the initialization data in a single-point storage system (such as Redis), the present application provides a unified way to ensure that each transaction has a unique identifier, and the transaction status can be tracked and verified. This reduces the situation where each R&D personnel needs to implement the initialization logic separately, and improves the consistency and security of the initialization data. By checking the preconditions and business data integrity before executing any transaction steps, the present application ensures the order and integrity of the transaction process, and prevents unauthorized step skipping or data tampering. This avoids the problem of uneven quality caused by the lack of a unified inspection mechanism in the prior art. By executing the business logic only after the current transaction step is verified, the present application ensures the continuity and consistency of the transaction process, and reduces the problems caused by illegal skipping of steps. This also helps R&D personnel focus more on the development of business logic rather than the implementation of security logic. As a result, the workload of R&D personnel in implementing anti-skipping and anti-tampering functions is reduced, and the security and integrity of transaction information are ensured. This not only improves the security of the system, but also simplifies the management of the transaction process, allowing R&D personnel to focus more on the development of business logic. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] 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 some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0033] Figure 1 A schematic diagram of a transaction processing method provided in an embodiment of the present application;

[0034] Figure 2 A schematic diagram of single-point information transmission provided in an embodiment of the present application;

[0035] Figure 3 Schematic diagrams of two application scenarios provided for embodiments of the present application;

[0036] Figure 4 A structural diagram of a transaction processing system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0037] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings 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.

[0038] To facilitate understanding of the technical solutions provided by the embodiments of the present application, the background technology involved in the embodiments of the present application will be described below.

[0039] As mentioned above, in past practice, the anti-skip and anti-tampering functions were often implemented by individual developers, which resulted in various implementation methods and varying quality. Some transactions may not have been adequately verified for security, and there is a risk of tampering or skipping.

[0040] Since each developer needs to independently implement anti-tampering and anti-skipping logic, this leads to a lot of code redundancy. In addition, as the business grows, these customized security logics become difficult to manage and maintain uniformly.

[0041] R&D personnel need to spend a lot of time on implementing and maintaining these security logics instead of focusing on the development of business logic, which greatly reduces the overall R&D efficiency.

[0042] Since there are no unified standards and processes to guide the implementation of anti-tampering and anti-skipping, the security implementation methods between different transactions may vary greatly, making it difficult to conduct unified evaluation and management.

[0043] In order to solve the above problems, the embodiment of the present application abstracts the business transaction process into three stages: transaction start, transaction process, and transaction end. At the beginning of the transaction, each link of the transaction is planned, and when the transaction proceeds to the next link, a single point is used to transmit information, such as redis. Figure 2 , Figure 2 A schematic diagram of single-point information delivery provided for an embodiment of the present application, including transaction 1, transaction 2 and transaction 3, which respectively use single-point information delivery.

[0044] By designing specialized components to handle the anti-skip and anti-tampering logic during the transaction process, a standardized and unified processing flow is achieved. This helps reduce quality issues caused by individual implementation differences and improves the security and stability of the overall system. All initialization data and serial numbers related to the target transaction are stored in a single-point storage system. This approach not only facilitates centralized management and access to data, but also simplifies subsequent data cleanup and maintenance. When the transaction is completed, the relevant data can be easily cleared to avoid data redundancy and potential security risks.

[0045] Moreover, the component-based design makes the system more modular and flexible. When adding new transaction types or adjusting existing transaction processes, it is only necessary to expand or modify the components accordingly, without making large-scale changes to the entire system. This helps reduce the cost and difficulty of system upgrades and maintenance.

[0046] It should be noted that the transaction processing method, system, device and medium provided in this application can be applied to the field of computer technology. The above is only an example and does not limit the application field of the transaction processing method, system, device and medium provided in this application. In addition, the embodiment of the present application may not limit the execution subject of the transaction processing. For example, the transaction processing method of the embodiment of the present application can be applied to data processing devices such as terminal devices or servers. Among them, the terminal device can be an electronic device such as a computer, a personal digital assistant (PDA). The server can be a stand-alone server, a cloud server, or a cluster server composed of multiple servers.

[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings 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.

[0048] The following is an example of an embodiment to illustrate a transaction processing method provided by the present application.

[0049] See also Figure 1 , Figure 1 A schematic diagram of a transaction processing method provided in an embodiment of the present application, including:

[0050] S101, initialize a target transaction, and store the initialization data obtained by initialization and the serial number of the target transaction in a single-point storage system.

[0051] At the beginning of a transaction, a unique serial number is created to identify the transaction. This is usually achieved through a combination of a business code (bizCode) and a business sequence number (bizSeqNo). The serial number is critical for tracking and querying transactions. In addition, other data structures and status information required for initializing the transaction need to be initialized. These initialization data may include the starting state of the transaction, the expected transaction steps, etc. After the initialization is completed, all the initialization data together with the serial number are stored in a single-point storage system (such as Redis) for use in subsequent transaction processing.

[0052] By generating a unique serial number at the beginning of a transaction and storing the initialization data in a single-point storage system (such as Redis), this application provides a unified way to ensure that each transaction has a unique identifier that can track and verify the transaction status. This reduces the need for each R&D staff to implement the initialization logic separately and improves the consistency and security of the initialization data.

[0053] S102. Before executing a transaction step, check whether the current transaction step meets the preconditions, and check whether the business data of the current transaction step has been tampered with.

[0054] Before executing any specific transaction step, you can verify whether the step meets its preconditions, for example, whether the previous step has been completed correctly. In addition, you need to verify whether the business data of the current step has not been tampered with to ensure the security and integrity of the transaction. If the data of the current step has been tampered with, or the preconditions are not met, the current step should not be executed, and additional security measures may need to be taken.

[0055] By checking the preconditions and business data integrity before executing any transaction steps, the present application ensures the order and integrity of the transaction process and prevents unauthorized step skipping or data tampering. This avoids the problem of uneven quality caused by the lack of a unified inspection mechanism in the prior art.

[0056] S103. When the current transaction step passes verification, the current transaction step is executed based on the initialization data.

[0057] Once the verification of the current step passes, it indicates that all necessary preconditions have been met and the data has not been tampered with. At this time, the current step can be safely executed. When executing the current step, the initialization data and other related business data may be referenced to complete the operation of the step. The execution result of the current step will also be recorded for verification of subsequent steps.

[0058] By executing the business logic only after the current transaction step has been verified, this application ensures the continuity and consistency of the transaction process and reduces problems caused by illegal skipping of steps. This also helps R&D personnel focus more on the development of business logic rather than the implementation of security logic.

[0059] S104: When all transaction steps of the target transaction are completed, clear the data in the single-point storage system.

[0060] When all steps of a transaction have been completed and the entire transaction is confirmed as successful, the temporary data stored in the single-point storage system is no longer needed. At this time, all stored data related to this transaction should be cleaned up to free up storage space and keep the system tidy. This also helps protect privacy and sensitive information and avoids the risks of unnecessary data retention.

[0061] In one possible implementation, when designing group components, in order to reduce the intrusion to the developer's code, code design is done in the form of annotations. The advantage of this is that developers can use annotations to identify and control different stages of the transaction process without changing the original business logic code. The following is a brief description and requirements of the three annotations:

[0062] @EnterService, the purpose is to mark the start of a transaction. The requirement is to define the transaction link. Initialize the data structure required for the transaction. Generate a unique identifier for the transaction (such as a serial number). Store the initialized data in a single-point storage system (such as Redis).

[0063] @ProcessService is used to identify the steps in a transaction. The requirements are to check whether the previous steps have been completed. Verify whether the business data has been tampered with. Ensure that the current step can be executed normally. Update the data in the single-point storage system.

[0064] @OutService, the purpose is to mark the end of the transaction. The requirement is to verify whether all steps have been completed. Clean up temporary data in the single-point storage system.

[0065] StepGroupList identifies the list that needs to be executed according to the steps in the group. StepMap records the steps that have been executed. BizData stores the transaction elements in each step for transaction use and tamper-proofing.

[0066] When defining the start annotation @EnterService, the concept of group is introduced, allowing multiple transaction groups to be defined and set as a single point of storage. This is done to handle two scenarios, see Figure 3 , Figure 3 Two application scenario diagrams are provided for the embodiments of the present application, including: the first one, the transaction link is known and is a single link: at the beginning of the transaction, all possible groups are defined and stored in a single point. The second one, the transaction link may change with the selection: allowing groups to be dynamically added or changed during the transaction.

[0067] In the embodiment of the present application, all possible groups are defined at the beginning of the transaction and set to a single point. Therefore, when defining the starting annotation, a concept of a group is added to the annotation. See the following content:

[0068]

[0069] In this code, two custom annotations @Group and @Step are defined. These two annotations may be used in transaction process management, especially to provide additional metadata information when defining different stages and steps of a transaction.

[0070] @Group is used to mark a class or method as belonging to a specific group. This concept of a group can be used to distinguish different transaction types, business logic blocks, or processing flows. It includes the following elements: groupId(): defines the unique number of the group, which is used to identify different transaction groups. groupName(): defines the name of the group to provide a more intuitive description. defaultGroupFlag(): returns a Boolean value indicating whether the group is the default group. If true, it means that the group is the default group; if false (default value), it means that the group is not the default group. steps(): defines the steps contained in the group, each step is identified by the @Step annotation.

[0071] @Step is used to mark specific steps in the transaction process. This annotation can be used to define the execution order of the transaction and the specific operations of each step at the code level. Including stepId(): defines the unique identifier of the step. stepName(): defines the name of the step.

[0072] At the beginning of a transaction, all possible groups can be defined and set to a single point (which can be a configuration center, a database, or a data structure in memory), so that these groups can be easily referenced in the transaction process.

[0073] By adding the defaultGroupFlag() attribute to the @Group annotation, the system can handle dynamic changes in groups during transactions. If a group is marked as the default group, then when it is necessary to switch to another group, if the new group does not exist or is unavailable, the system can fall back to the default group, thus ensuring the continuity and stability of the transaction.

[0074] From the above code, we can know that the embodiment of the present application adds a step annotation to identify each step. In addition, we can also define whether the group is the default group, which is to deal with the switching from the default group to another group when the group changes dynamically during the transaction. The demo defined in the specific business code can be:

[0075]

[0076]

[0077]

[0078] The above code example shows how to dynamically switch groups in a transaction process based on business logic. This process is implemented through the StepGroupUtil.switchGroup method, which allows the path of the transaction process to be changed based on conditions at runtime.

[0079] @RequestMapping("step1"): Spring framework annotation, used to map HTTP requests to specific processing methods. Here, the mapping is to the path "step1".

[0080] @EnterService: is used to mark the entry point of the transaction process and defines the business code and groups involved in the transaction. As shown in the above code, business code biz001 and four groups are defined, each containing three steps. Group1 is marked as the default group.

[0081] @EnterService.Group: used to define a group in the transaction process.

[0082] @EnterService.Group.Step: used to define a step in the transaction process.

[0083] If the value of stepFlag is "-2", the StepGroupUtil tool class is used to dynamically switch groups. First, it switches to group1, then to group3. Finally, stepFlag is saved as business data and "step1" is returned.

[0084] The following is an explanation of how to store objects. The data structure is as follows:

[0085]

[0086]

[0087] stepGroupList identifies the activity groups in the current transaction process. It contains the following information:

[0088] defaultFlag: A Boolean value indicating whether this group is the default group. If it is the default group, it will be used when no other specific group is specified.

[0089] groupId: The unique identifier of the group, used to reference and identify the group within the program.

[0090] groupName: The name of the group, providing a descriptive identification of the group to help understand the purpose of the group.

[0091] stepList: An array listing the steps that need to be executed in this group.

[0092] stepMap records the steps that have been performed and their status. Each step identifier is associated with a unique hash value or other identifier to verify the integrity and tamper-proof of the step.

[0093] bizData stores the specific business data in each step, which are the core elements of the transaction and are used for transaction execution and subsequent review.

[0094] The data structure allows the system to flexibly handle complex multi-step transaction processes while ensuring that the execution of each step can be effectively tracked and verified. By centrally managing step information, execution status, and business data, the system can ensure the integrity of the transaction: verify that the execution of the step has not been tampered with through the hash value or other identifier in the stepMap. Provide transaction traceability: The execution of each step and data changes are recorded to facilitate subsequent review and troubleshooting. Support dynamic process management: support dynamic adjustment of the execution process according to business logic during the transaction process through defaultFlag and stepList.

[0095] The following is an explanation of the EnterProcess principle:

[0096] / / 1. Initialize the scene instance. The combination of bizCode and bizSeqNo here can be regarded as a unique serial number.

[0097] stepGroupUtil.createStepContext(bizCode,bizSeqNo);

[0098] / / 2. Processing groups

[0099] handleGroup(enterService.dynamicGroup(),bizCode,enterService.groups());

[0100] / / 3. Save step business data

[0101] stepGroupUtil.saveBizData("enterStep");

[0102] / / 4. Dynamically specify the next step (optional)

[0103] stepGroupUtil.addDynamicStep(handleStep(enterService.nextStep()),"");

[0104] / / 5. Save the stride instance

[0105] stepGroupUtil.saveStepContextCache(bizCode,bizSeqNo);

[0106] / / 6. Cut groups according to business logic (optional)

[0107] stepGroupUtil.switchGroup();

[0108] In the step of stepGroupUtil.createStepContext(bizCode,bizSeqNo), bizCode (business code) and bizSeqNo (business sequence number) are combined as a unique identifier (serial number) to identify the transaction. This serial number is critical for tracking and querying transactions. Through the createStepContext method, the transaction scenario instance is initialized, which may involve setting the initial state, creating necessary data structures, etc.

[0109] handleGroup(enterService.dynamicGroup(),bizCode,enterService.groups()); This step handles the group to which the transaction belongs. The dynamicGroup() method may return the current dynamic group information, while enterService.groups() returns all possible group information. The handleGroup method may be responsible for determining which group to use based on the business code and the current dynamic group information, and initializing the group.

[0110] stepGroupUtil.saveBizData("enterStep"); In this step, save the business data related to the current step. This data may include user input, transaction parameters, etc., which are crucial to transaction execution.

[0111] stepGroupUtil.addDynamicStep(handleStep(enterService.nextStep()),"");This step is optional and is used to dynamically specify the next step of the transaction. enterService.nextStep() may return detailed information about the next step, and the handleStep method may be used to process this information.

[0112] stepGroupUtil.saveStepContextCache(bizCode,bizSeqNo); This step saves the current step context information to a cache, such as Redis. This helps maintain the continuity of transaction state across multiple steps or sessions.

[0113] stepGroupUtil.switchGroup(); This step is also optional and is used to switch to a different group based on business logic during the transaction. This may involve updating the status of the current group or loading new group information.

[0114] Together, these steps ensure the integrity and consistency of transaction initialization, execution, and state management. By using unique serial numbers and dynamic processing groups, the system can flexibly handle a variety of transaction scenarios while ensuring data security and integrity. Saving business data and step context in the cache helps maintain transaction continuity and consistency across steps. The ability to dynamically specify the next step and switch groups enables the system to adapt to complex business needs and changes.

[0115] The following is an explanation of the ProcessService principle.

[0116] / / 1. Check the pre-steps

[0117] stepGroupUtil.checkPrevSteps(bizCode,bizSeqNo,processService.currentStep(),processService.nextStep());

[0118] / / Target method execution

[0119] Object result=joinPoint.proceed();

[0120] / / 2. Dynamically specify the next step (optional)

[0121] stepGroupUtil.addDynamicStep(handleStep(processService.nextStep()), processService.currentStep());

[0122] / / 3. Cut groups according to business logic (optional)

[0123] stepGroupUtil.switchGroup();

[0124] / / 4. Save step business data

[0125] stepGroupUtil.saveBizData(processService.currentStep());

[0126] / / 5. Set the current step through

[0127] stepGroupUtil.stepSuccess(bizCode,bizSeqNo,processService.currentStep());

[0128] Before executing the current step, first check whether all the previous steps have been completed. This is to ensure the order and integrity of the transaction process.

[0129] Object result = joinPoint.proceed() is used to execute the actual business logic. joinPoint.proceed() is used to call the original method in aspect programming. The original method here may be the business logic for processing the current step.

[0130] The next step is determined dynamically based on the outcome of the current step. This allows the transaction process to flexibly change based on business needs.

[0131] stepGroupUtil.switchGroup() is used to indicate switching to a different group based on business logic if necessary. This may involve changing the context or state of the transaction process.

[0132] stepGroupUtil.saveBizData(processService.currentStep()); Saves the business data of the current step, which may include transaction elements, user input and other information for transaction use and tamper-proofing.

[0133] stepGroupUtil.stepSuccess(bizCode,bizSeqNo,processService.currentStep()); Mark the current step as successfully completed. This may involve updating the step status, recording the completion time, etc.

[0134] This aspect ensures that each step in the transaction process can be executed in the predetermined order and that the business data of each step can be correctly processed and saved. By checking the previous steps, executing business logic, dynamically specifying the next step, switching groups, saving business data, and marking step status, this aspect provides a complete mechanism to manage and verify each link of the transaction process. This helps prevent unauthorized step skipping or data tampering, ensuring the security and reliability of transactions.

[0135] The following is a description of OutProcess:

[0136] / / 1. Check all steps

[0137] stepGroupUtil.checkAllSteps(bizCode,bizSeqNo);

[0138] / / Target method execution

[0139] Object result=joinPoint.proceed();

[0140] / / 2. Clean up the stride scene

[0141] stepGroupUtil.cleanStepContext(bizCode,bizSeqNo);

[0142] Before executing the target method, first verify that all steps in the transaction process have been completed. This is to ensure that all necessary steps have been executed and the data is complete before ending the transaction.

[0143] Execute the actual business logic. joinPoint.proceed() is the call to the original method in aspect programming. The original method here may be the business logic for processing the end of the transaction.

[0144] After the transaction process is completed, all temporary data and context information related to the transaction are cleaned up. This helps free up resources and avoids data leakage or residue.

[0145] Dynamically adding steps using addDynamicStep is an optional operation used to dynamically add steps to a transaction flow. This allows the system to dynamically adjust steps based on business needs without resetting the entire step array.

[0146] The integrity of the transaction process and the cleanliness of the data are ensured. By checking the completion of all steps, it can be ensured that all necessary links of the transaction have been executed. After executing the target method, cleaning up the step scene helps maintain the performance of the system and the security of the data. Dynamically adding steps provides flexibility, so that the transaction process can be adjusted according to actual business needs without setting up too many step arrays at the beginning, thereby improving the scalability and adaptability of the system.

[0147] In multi-step transactions, data structure design is key because it needs to support step tracking, data verification, and status updates. In the embodiment of the present application, a transaction status table is maintained in Redis or a database, and each transaction has a unique identifier (such as UUID). The table contains information such as the current step of the transaction, completed steps, business data, timestamps, etc. The detailed information of each step is defined in the code or in the database, including step name, preconditions, execution logic, expected output, etc. This information can be used for step verification. Design a business data model according to business requirements to ensure that each step can correctly read, modify, and verify this data.

[0148] Before executing each step, check whether the previous step has been completed. This can be achieved by querying the transaction status table. If the previous step is not completed or there is an error, the current step should be rejected. During the execution of each step, the input and output data are verified to ensure the integrity and consistency of the data. This can be achieved by using verification rules, regular expressions, database constraints, etc.

[0149] Using Redis or a database as a single-point storage system can effectively prevent step skipping during the transaction process. After each step is completed, the current step information in the transaction status table is updated. During step verification, step skipping is prevented by checking whether the current step is consistent with the expected step.

[0150] In order to reduce the frequency of access to single-point storage systems such as Redis or databases, the embodiments of the present application use ThreadContext or other thread-local variables to cache the transaction status and data of the current thread. In this way, within the same thread, there is no need to query Redis or the database every time the transaction status is accessed multiple times. Where possible, multiple operations are merged into a batch for processing, and then Redis or the database is updated at one time. This can reduce the number of network IO and database operations. For query-intensive applications, a read-write separation strategy can be considered. That is, read operations and write operations are distributed to different Redis instances or database nodes respectively to reduce the load on a single node.

[0151] The above are some specific implementations of the transaction processing method provided in the embodiment of the present application. Based on this, the present application also provides a corresponding transaction processing system. The system provided in the embodiment of the present application will be introduced from the perspective of functional modularization. Figure 4 A structural diagram of a transaction processing system provided in an embodiment of the present application.

[0152] The system comprises:

[0153] The storage unit 110 is used to initialize the target transaction and store the initialization data and the serial number of the target transaction obtained by initialization in a single-point storage system;

[0154] The verification unit 111 is used to verify whether the current transaction step meets the preconditions before executing the transaction step, and to verify whether the business data of the current transaction step has been tampered with;

[0155] An execution unit 112, configured to execute the current transaction step based on the initialization data when the current transaction step passes verification;

[0156] The clearing unit 113 is used to clear the data in the single-point storage system when all transaction steps of the target transaction are completed.

[0157] The embodiments of the present application also provide corresponding devices and computer storage media for implementing the test method solutions provided in the embodiments of the present application.

[0158] The device includes a memory and a processor, the memory is used to store instructions or codes, and the processor is used to execute the instructions or codes so that the device executes the test method described in any embodiment of the present application.

[0159] The computer storage medium stores codes, and when the codes are executed, a device executing the codes implements the test method described in any embodiment of the present application.

[0160] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0161] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0162] It should be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.

[0163] It should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0164] It should also be noted that, in this article, relational terms such as first and second, etc. 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", "comprise" 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 sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0165] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0166] 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 transaction processing method, characterized in that: include: Initializing the target transaction, and storing the initialization data obtained by initialization and the serial number of the target transaction in a single-point storage system; Before executing a transaction step, check whether the current transaction step meets the preconditions, and check whether the business data of the current transaction step has been tampered with; When the current transaction step passes the verification, executing the current transaction step based on the initialization data; When all transaction steps of the target transaction are completed, the data in the single-point storage system is cleared.

2. The method according to claim 1, characterized in that When the current transaction step passes the verification, after executing the current transaction step based on the initialization data, the method further includes: Verify the business data input and output when executing the current transaction step.

3. The method according to claim 1, characterized in that When the current transaction step passes the verification, after executing the current transaction step based on the initialization data, the method further includes: Update the transaction status information of the current transaction step to the completed status.

4. The method according to claim 1, characterized in that: Before executing the transaction step, after checking whether the current transaction step meets the precondition and checking whether the business data of the current transaction step has been tampered with, the method further includes: Based on the execution order of the transaction steps of the target transaction, check whether there is any step skipping in the current transaction step.

5. The method according to claim 1, characterized in that When all transaction steps of the target transaction have been completed, before clearing the data in the single-point storage system, the method further includes: Verify whether all transaction steps of the target transaction have been completed, and verify whether the business data corresponding to the target transaction meets the integrity and consistency requirements; When all transaction steps of the target transaction are completed, clearing the data in the single-point storage system includes: When all transaction steps of the target transaction have been completed and the business data corresponding to the target transaction meets the integrity and consistency requirements, the data in the single-point storage system is cleared.

6. The method according to claim 1, characterized in that The initialization data includes group information and a transaction link, wherein the group information is used to indicate that the to-be-executed group is adjusted based on the transaction link during the transaction process, so that the transaction steps corresponding to the to-be-executed group are sequentially executed based on the target identifier.

7. The method according to claim 1, characterized in that When the current transaction step passes the verification, after executing the current transaction step based on the initialization data, the method further includes: Based on the execution result of the current transaction step, determine the next transaction step to be executed.

8. A transaction processing system, characterized in that: include: A storage unit, used to initialize the target transaction and store the initialization data obtained by initialization and the serial number of the target transaction in a single-point storage system; A verification unit, used to verify whether the current transaction step meets the preconditions before executing the transaction step, and to verify whether the business data of the current transaction step has been tampered with; An execution unit, configured to execute the current transaction step based on the initialization data when the current transaction step passes verification; The clearing unit is used to clear the data in the single-point storage system when all transaction steps of the target transaction are completed.

9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the transaction processing method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on the terminal device, the terminal device executes the transaction processing method according to any one of claims 1 to 7.