Transaction processing method, apparatus, computer system, and storage medium

By referencing annotation objects and context objects in the target project, the transaction template tool is used to implement static invocation of transactions, which solves the problem of cumbersome transaction operations in the existing technology and improves the convenience of transaction execution and the stability of the system.

CN113760467BActive Publication Date: 2026-03-17BEIJING JINGDONG TUOXIAN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-15
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

In business processing, existing technologies involve cumbersome transaction operations, resulting in long execution times, high resource consumption, and difficulty in management in multi-threaded environments.

Method used

By using a transaction template tool, static invocation and management of transactions are achieved by referencing annotation objects, context objects, and transaction template encapsulation objects in the project object model file of the target project, thus avoiding the occurrence of large transactions.

Benefits of technology

It simplifies the transaction operation process, reduces resource consumption, improves the convenience of transaction execution and the robustness of the system, and reduces the burden on developers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113760467B_ABST
    Figure CN113760467B_ABST
Patent Text Reader

Abstract

The present disclosure provides a transaction processing method, comprising: obtaining a transaction request instruction; in response to the transaction request instruction, calling a transaction template tool; wherein the transaction template tool is referenced in a project object model file in a target project, and the transaction template tool comprises an annotation object, a context object and a transaction template encapsulation object for executing a transaction; and executing the transaction based on the transaction template tool. The present disclosure also provides a transaction processing device, a computer system and a computer readable storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more specifically, to a transaction processing method, apparatus, computer system, and storage medium. Background Technology

[0002] With the rapid development of artificial intelligence, automatic control, communication, and computer technologies, transaction operations are increasingly being used for business processing in all aspects of life. Examples include logistics, online shopping, and online money transfers. Transactions possess characteristics such as atomicity, consistency, isolation, and durability, ensuring data consistency.

[0003] In the process of realizing the present invention, the inventors discovered that the related technology has at least the following problems: when performing business processing, in order to ensure that the transaction takes effect, the operation of the transaction is relatively cumbersome. Summary of the Invention

[0004] In view of the above, this disclosure provides a transaction processing method, apparatus, computer system, and computer-readable storage medium.

[0005] One aspect of this disclosure provides a transaction processing method, including:

[0006] Obtain transaction request instructions;

[0007] In response to the aforementioned transaction request instruction, the transaction template tool is invoked; wherein, the aforementioned transaction template tool is referenced in the project object model file in the target project and is used to execute the aforementioned transaction; the aforementioned transaction template tool includes annotation objects, context objects, and transaction template encapsulation objects; and

[0008] Execute the above transaction based on the transaction template tool described above.

[0009] According to embodiments of this disclosure, executing the above-mentioned transaction based on the above-mentioned transaction template tool includes:

[0010] Based on the above-mentioned annotated objects, enable the transaction switch for the above-mentioned transactions; and

[0011] Based on the transaction template encapsulation object and the context object mentioned above, the transaction template in the transaction template encapsulation object is statically called to execute the transaction.

[0012] According to embodiments of this disclosure, it further includes:

[0013] The tool for creating the above-mentioned transaction templates includes:

[0014] Create a project file decoupled from the target project mentioned above; this project file includes annotation objects, context objects, and transaction template encapsulation objects; and

[0015] Package the above project files to generate the template transaction tool.

[0016] According to embodiments of this disclosure, the creation of the project file decoupled from the target project includes:

[0017] Create an annotation object; wherein the annotation object includes an annotation that enables the transaction switch for the above transaction;

[0018] Create a context object; the context object contains the context of the target project.

[0019] Based on the aforementioned context object, obtain the transaction template; and

[0020] Create a transaction template encapsulation object to encapsulate the above transaction template so that the above transaction template can be invoked in a static way.

[0021] According to embodiments of this disclosure, the creation of the project file decoupled from the target project further includes:

[0022] Configure the address of the above annotation object into the extension mechanism file of the above target project so that the above annotation object can be automatically assembled when the above transaction is executed.

[0023] According to embodiments of this disclosure, the above method further includes:

[0024] Determine whether the above transaction was executed successfully;

[0025] If the above transaction executes successfully, submit the result of the successful transaction execution; and

[0026] If the above transaction fails, a transaction rollback will be performed.

[0027] Another aspect of this disclosure provides a transaction processing apparatus, comprising:

[0028] The acquisition module is used to acquire transaction request instructions;

[0029] The calling module is used to invoke the transaction template tool in response to the aforementioned transaction request instruction; wherein the aforementioned transaction template tool is referenced in the project object model file in the target project and is used to execute the aforementioned transaction; the aforementioned transaction template tool includes annotation objects, context objects, and transaction template encapsulation objects; and

[0030] The execution module is used to execute the above transactions based on the transaction template tool.

[0031] According to embodiments of this disclosure, the above-described apparatus further includes:

[0032] A creation module is used to create the aforementioned transaction template tool; the creation module includes:

[0033] A creation unit is used to create project files decoupled from the aforementioned target project; these project files include annotation objects, context objects, and transaction template encapsulation objects; and

[0034] The packaging unit is used to package the above-mentioned project files and generate the above-mentioned template transaction tool.

[0035] In another aspect of this disclosure, a computer system is also provided, comprising:

[0036] One or more processors;

[0037] Memory, used to store one or more programs.

[0038] When the above one or more programs are executed by the above one or more processors, the above one or more processors implement the above method.

[0039] In another aspect of this disclosure, a computer-readable storage medium is provided having executable instructions stored thereon, which, when executed by a processor, cause the processor to implement the methods described above.

[0040] In another aspect, this disclosure provides a computer program product including a computer program comprising computer executable instructions that, when executed, implement the transaction processing method described above.

[0041] According to the embodiments of this disclosure, by employing the following technical means—namely, obtaining a transaction request instruction; responding to the transaction request instruction and invoking a transaction template tool; wherein the transaction template tool is referenced in the project object model file in the target project and is used for executing transactions, and the transaction template tool includes an annotation object, a context object, and a transaction template encapsulation object; and executing transactions based on the transaction template tool—the problem of introducing large transactions through transaction annotations and needing to inject classes containing transaction templates into the Spring Boot context is avoided. Therefore, the technical problem of cumbersome transaction operations in business processing in the prior art is at least partially overcome, thereby achieving the technical effect of convenient transaction execution. Attached Figure Description

[0042] The above and other objects, features and advantages of this disclosure will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:

[0043] Figure 1An exemplary system architecture to which the transaction processing methods and apparatus of this disclosure can be applied is illustrated schematically;

[0044] Figure 2 This illustration schematically depicts an application scenario of the transaction processing method according to embodiments of the present disclosure;

[0045] Figure 3 A flowchart illustrating a transaction processing method according to an embodiment of the present disclosure is shown schematically;

[0046] Figure 4 A tool for creating transaction templates according to an embodiment of this disclosure is illustrated schematically;

[0047] Figure 5 This illustration schematically shows the creation of an engineering project file decoupled from the target project according to an embodiment of this disclosure;

[0048] Figure 6 A flowchart illustrating the execution of a transaction according to an embodiment of the present disclosure is shown schematically;

[0049] Figure 7 A flowchart illustrating a transaction processing method according to another embodiment of the present disclosure is shown schematically.

[0050] Figure 8 A block diagram of a transaction processing apparatus according to embodiments of the present disclosure is schematically shown; and

[0051] Figure 9 A block diagram of a computer system suitable for implementing a transaction processing method according to an embodiment of the present disclosure is shown schematically. Detailed Implementation

[0052] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.

[0053] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0054] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.

[0055] When using expressions such as "at least one of A, B, and C," the expression should generally be interpreted in accordance with the meaning commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, systems having A alone, having B alone, having C alone, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.). Similarly, when using expressions such as "at least one of A, B, or C," the expression should generally be interpreted in accordance with the meaning commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, or C" should include, but is not limited to, systems having A alone, having B alone, having C alone, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.).

[0056] Embodiments of this disclosure provide a transaction processing method and apparatus. The method includes obtaining a transaction request instruction; in response to the transaction request instruction, invoking a transaction template tool; wherein the transaction template tool is referenced in a project object model file in a target project and is used for executing transactions, and the transaction template tool includes annotation objects, context objects, and transaction template encapsulation objects; and executing transactions based on the transaction template tool.

[0057] Figure 1 An exemplary system architecture 100 to which transaction processing methods and apparatus can be applied according to embodiments of this disclosure is illustrated schematically. It should be noted that... Figure 1 The examples shown are merely examples of system architectures that can be applied to the embodiments of this disclosure, in order to help those skilled in the art understand the technical content of this disclosure, but do not mean that the embodiments of this disclosure cannot be used in other devices, systems, environments or scenarios.

[0058] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, and 103, a network 104, and a server 105. The network 104 serves as a medium for providing a communication link between the terminal devices 101, 102, and 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0059] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as shopping applications, web browser applications, online banking applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (for example only).

[0060] Terminal devices 101, 102, and 103 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0061] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using terminal devices 101, 102, and 103 (for example only). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.

[0062] It should be noted that the transaction processing method provided in this embodiment can generally be executed by server 105. Correspondingly, the transaction processing device provided in this embodiment can generally be located in server 105. The transaction processing method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the transaction processing device provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Alternatively, the transaction processing method provided in this embodiment can also be executed by terminal devices 101, 102, or 103, or by other terminal devices different from terminal devices 101, 102, or 103. Correspondingly, the transaction processing device provided in this embodiment can also be located in terminal devices 101, 102, or 103, or in other terminal devices different from terminal devices 101, 102, or 103.

[0063] For example, the transaction template tool may originally be stored in any one of terminal devices 101, 102, or 103 (e.g., terminal device 101, but not limited thereto), or it may be stored on an external storage device and imported into terminal device 101. Then, terminal device 101 may execute the transaction processing method provided in the embodiments of this disclosure locally, or send the transaction to other terminal devices, servers, or server clusters, and have the other terminal devices, servers, or server clusters that receive the transaction execute the transaction processing method provided in the embodiments of this disclosure.

[0064] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0065] According to embodiments of this disclosure, Spring Boot is a novel framework designed to simplify the initial setup and development process of new Spring applications. This framework uses specific configuration methods, eliminating the need for developers to define boilerplate configurations.

[0066] According to embodiments of this disclosure, a transaction generally refers to something to be done or something that has been done. In computer terminology, it refers to a unit of program execution that accesses and may update various data items in a database. Transactions are typically caused by the execution of user programs written in high-level database manipulation languages ​​or programming languages ​​(such as SQL, C++, or Java) and are delimited by statements (or function calls) of the form begin transaction and end transaction. A transaction consists of all the operations performed between the start of the transaction and the end of the transaction. A transaction is a logically grouped set of operations in which the individual execution units that make up the transaction must either all succeed or all fail. The properties of a transaction include atomicity, consistency, isolation, and durability.

[0067] Figure 2 The diagram illustrates an application scenario of the transaction processing method according to an embodiment of the present disclosure.

[0068] like Figure 2As shown, an application scenario for the transaction processing method disclosed herein could be, for example, Li Si transferring 100 yuan to Zhang San. During the transfer process, money is added to Zhang San's account, and money is deducted from Li Si's account; these two operations need to be performed in a specific order. If a problem occurs between these two operations, for example, Zhang San's account receives 100 yuan, but Li Si's account does not correspondingly deduct 100 yuan, then the transfer process has encountered a problem. In this situation, using transactions ensures that either both operations succeed or both fail.

[0069] According to other embodiments of this disclosure, the transaction processing method of this disclosure can also be applied in the following scenario: In an order placement process, after payment is completed, it is necessary to modify the payment status of both the order record and the settlement record. In this case, using transactions, the payment status operations on the order record and the settlement record can either succeed or fail together.

[0070] Figure 3 A flowchart illustrating a transaction processing method according to an embodiment of the present disclosure is shown schematically.

[0071] like Figure 3 As shown, the method includes operations S301 to S303.

[0072] In operation S301, obtain the transaction request instruction.

[0073] In operation S302, in response to the transaction request instruction, the transaction template tool is invoked; wherein, the transaction template tool is referenced in the project object model file in the target project and is used to execute the transaction, the transaction template tool includes annotation objects, context objects and transaction template wrapper objects.

[0074] When operating S303, a transaction is executed based on the transaction template tool.

[0075] In implementing this disclosure, it was discovered that transactions can be implemented in several ways. For example, using transaction annotations. With transaction annotations, simply adding the `@Transactional` annotation to the implementing class or a method of the implementing class guarantees the transaction of that method. However, the transaction annotation method has many problems. For example:

[0076] (1) When a transaction contains many operations such as querying, updating, and inserting data, the execution time of the transaction will naturally become very long.

[0077] (2) When there is a lot of contention for locks, when all connections operate on the same data at the same time, there will be a queue and waiting, and the transaction time will naturally become longer.

[0078] (3) There are other non-DB operations in the transaction, such as some RPC requests. RPC requests are unstable and affected by many factors, such as network fluctuations and slow response of downstream services. If these factors occur, a large number of large transactions will accumulate, which may lead to the exhaustion of MySQL connections, causing the service to appear dead, and thus causing a cascading failure.

[0079] (4) The implementation of the @Transactional annotation involves Spring generating a proxy class for the bean. At runtime, it checks whether the class or method has the annotation to determine whether to start a transaction. Therefore, if it is not used correctly, Spring's IOC mechanism may fail to detect the bean being used, causing the proxy class to be unable to proxy the operation, resulting in the annotation not taking effect, and thus the transaction not working.

[0080] Alternatively, transactions can be implemented using transaction templates. This involves obtaining a transaction template bean and providing an anonymous inner class to offer transaction templates. Compared to transaction annotations, this avoids the introduction of large transactions, has a shorter processing time, and prevents service freezes caused by the accumulation of large transactions.

[0081] However, the current method of implementing transactions through transaction templates also has many problems. For example, the current transaction template method requires injecting the class containing the transaction template into the Spring Boot context so that when performing business processing, the corresponding class containing the transaction template can be found and called through @Resource or @Autowired, so that the transaction can be implemented through the transaction template in the class.

[0082] The existing transaction template is not convenient enough. First, the transaction template class needs to be injected into the Spring Boot application context. Similarly, annotations need to be added to the startup class to enable or disable transactions. Then, the corresponding class can be called using @Resource or @Autowired.

[0083] Furthermore, in multi-threaded environments, such as concurrent asynchronous execution environments where a method executes multiple times simultaneously, the corresponding bean cannot be obtained through annotations. Instead, it needs to be obtained within the Spring Boot application context and then transaction operations performed.

[0084] Therefore, the commonly used transaction template approach undoubtedly increases the complexity of transaction implementation and distracts developers.

[0085] According to embodiments of this disclosure, the transaction template tool is used to manage and execute transactions. The basis of this method is still to implement transactions using transaction templates, which can conveniently control the granularity of transaction execution and avoid the occurrence of large transactions.

[0086] According to embodiments of this disclosure, the transaction template tool is referenced in the project object model file (POM file) of the target project. When the target project needs to use the transaction template tool, the transaction template tool is referenced in the project object model file (POM file) of the target project. After this operation is completed, the target project can directly use the transaction template tool to execute transactions after it starts.

[0087] According to embodiments of this disclosure, the transaction template tool includes annotation objects that contain annotations for starting transactions. The transaction template tool encompasses the annotations used to initiate transactions within these annotation objects, rather than employing the prior art method of configuring a startup file for a project and adding annotations to that file.

[0088] According to embodiments of this disclosure, by placing the annotation object into the transaction template tool, there is no need to pay attention to the precautions for starting a transaction, making the transaction starting operation convenient.

[0089] According to embodiments of this disclosure, the transaction template tool also includes a context object, which can be used to obtain and call the transaction template in the transaction template encapsulation object. This eliminates the need to use existing methods such as @Resource or @Autowired to call the corresponding transaction template and eliminates the need to pay attention to precautions during transaction execution, making transaction execution operations convenient.

[0090] In summary, the transaction template tool of this disclosure can, on the one hand, conveniently control the granularity of transaction execution and avoid the occurrence of large transactions; on the other hand, it eliminates the need to pay attention to the precautions during transaction initiation and execution, making transaction execution operations convenient.

[0091] The following is for reference. Figures 4-6 In conjunction with specific embodiments, Figure 3 The method shown will be further explained.

[0092] Figure 4 A tool for creating transaction templates according to an embodiment of this disclosure is illustrated schematically.

[0093] like Figure 4 As shown, the transaction template creation tool can include the following operations S401 to S402.

[0094] In operation S401, a project file is created that is decoupled from the target project; the project file includes annotation objects, context objects, and transaction template encapsulation objects.

[0095] In S402, the project files are packaged to generate a template transaction tool.

[0096] According to embodiments of this disclosure, the creation of the transaction template tool is decoupled from the target project. The project file can be a separate Maven project file, within which configuration classes are created to obtain annotation objects and context objects.

[0097] According to embodiments of this disclosure, the project files are packaged to generate a template transaction tool (trans-tool-spring-boot-starter). Specifically, a packaging tool, such as the mvn tool, can be used to package the project files into a JAR file to obtain the transaction template tool.

[0098] According to the embodiments of this disclosure, because the anonymous inner class submission method is used, the granularity of transactions can be easily controlled during code review, avoiding the occurrence of large transactions. This improves code standardization, reduces the burden on developers, and allows code reviewers to provide a more intuitive assessment of the rationality of transactions, reducing deployment risks. It also reduces the workload of developers, allowing them to focus more on business development, while ensuring a more robust and secure system.

[0099] Figure 5 The illustration schematically depicts the creation of an engineering project file decoupled from the target project according to an embodiment of this disclosure.

[0100] like Figure 5 As shown, creating an engineering project file decoupled from the target project can include the following operations S501 to S504.

[0101] In operation S501, an annotation object is created; the annotation object includes annotations that enable or disable transactions.

[0102] In operation S502, a context object is created; the context object stores the context object of the target project.

[0103] When operating S503, obtain the transaction template based on the context object.

[0104] In operation S504, a transaction template encapsulation object is created to encapsulate the transaction template so that the transaction template can be invoked in a static call manner.

[0105] According to embodiments of this disclosure, creating an annotation object can be achieved by creating a configuration class in the project file, adding the annotation @EnableTransactionManagement to enable transactions within the configuration class, and thus obtaining the annotation object.

[0106] According to embodiments of this disclosure, in the project file of this disclosure, the context of the target project stored in the context object is directly used to obtain the transaction template based on the context object.

[0107] According to embodiments of this disclosure, a static utility class is obtained before the transaction template encapsulation object is generated; the static utility class TransTool can be developed by the user, but is not limited to this, as long as it is a class that can encapsulate the transaction template and provide a static calling method.

[0108] According to embodiments of this disclosure, a static utility class is used to encapsulate the transaction template `TransactionTemplate`, thereby generating a transaction template encapsulation object. This transaction template encapsulation object provides a way to statically invoke the transaction template. This static invocation method can be understood as allocating memory directly after the target project starts, loading the transaction template into that memory, and then invoking the transaction template. In this embodiment of the disclosure, the transaction template uses a static invocation method, which is more convenient.

[0109] According to embodiments of this disclosure, before packaging the project files and generating the template transaction tool, it is also necessary to configure the address of the annotation object into the extension mechanism file of the target project.

[0110] According to embodiments of this disclosure, the addresses of annotation objects and context objects are configured in the extension mechanism file of the target project. Specifically, the addresses of annotation objects and context objects can be configured in the Spring Boot extension mechanism file (spring.factories file) under the path / src / main / resources / META-INF / , so that the annotation objects can be automatically configured when the target project starts.

[0111] Figure 6 A flowchart illustrating the execution of a transaction according to an embodiment of this disclosure is shown schematically.

[0112] like Figure 6 As shown, the execution of a transaction includes operations S601 to S602.

[0113] When operating S601, the transaction switch is enabled based on the annotation object.

[0114] In operation S602, based on the transaction template encapsulation object and the context object, the transaction template in the transaction template encapsulation object is statically called in order to execute the transaction.

[0115] According to embodiments of this disclosure, the transaction template tool starts a transaction based on the annotation object, since the annotation object already contains a transaction switch annotation to enable the transaction. In this disclosure, the transaction template tool uses a context object to statically call the transaction template to execute the transaction. This static calling method of the transaction template is achieved through a static utility class.

[0116] According to embodiments of this disclosure, the implementation method adopted in this disclosure is to create a transaction template encapsulation object, encapsulate the transaction template separately, and invoke the transaction template statically based on the context object when in use. This differs from the prior art, which injects the transaction template into the corresponding Spring Boot context object through a configuration class and then invokes the corresponding transaction template using annotations such as @Resource or @Autowired when in use.

[0117] According to embodiments of this disclosure, the transaction template tool of this disclosure is more convenient and less prone to errors in creating target projects and executing transactions using target projects compared to existing methods of creation and invocation.

[0118] According to embodiments of this disclosure, transactions are implemented using a transaction template tool, eliminating the need to concern oneself with the precautions for initiating and using transactions. Furthermore, in a multi-threaded environment, the transaction template tool automatically ensures the correct injection of multi-threaded objects. This disclosure provides a convenient and efficient method for implementing transactions.

[0119] Figure 7 A flowchart illustrating a transaction processing method according to another embodiment of the present disclosure is shown schematically.

[0120] like Figure 7 As shown, the execution of a transaction includes operations S710 to S740, S751, and S752.

[0121] When operating the S710, obtain the transaction request instruction.

[0122] When operating S720, in response to a transaction request command, the transaction template tool is invoked; the transaction template tool is referenced in the project object model file in the target project and is used to execute transactions. The transaction template tool includes annotation objects, context objects, and transaction template wrapper objects.

[0123] When operating the S730, transactions are executed based on the transaction template tool.

[0124] When operating on S740, determine whether the transaction execution was successful;

[0125] In operation S751, if the transaction executes successfully, the successful transaction result is committed; and

[0126] In operation S752, if a transaction fails, a transaction rollback is performed.

[0127] According to embodiments of this disclosure, atomic operations of a transaction are achieved by operating S740, S751, and S752.

[0128] Figure 8 A block diagram of a transaction processing apparatus according to an embodiment of the present disclosure is shown schematically.

[0129] like Figure 8 As shown, the transaction processing device 800 includes an acquisition module 810, a calling module 820, and an execution module 830.

[0130] The acquisition module 810 is used to acquire transaction request instructions.

[0131] Module 820 is invoked in response to a transaction request instruction to invoke the transaction template tool. The transaction template tool is referenced in the project object model file in the target project and is used to execute transactions. The transaction template tool includes annotation objects, context objects, and transaction template wrapper objects.

[0132] Execution module 830 is used to execute transactions based on transaction template tools.

[0133] According to embodiments of this disclosure, the transaction processing apparatus further includes:

[0134] The creation module is used to create transaction template tools; the creation module includes:

[0135] The creation unit is used to create project files decoupled from the target project; these project files include annotation objects, context objects, and transaction template encapsulation objects; and

[0136] The packaging unit is used to package project files and generate template transaction tools.

[0137] According to embodiments of this disclosure, executing a transaction based on a transaction template tool includes:

[0138] A transaction switch that enables transactions based on annotation objects; and

[0139] Based on the transaction template encapsulation object and the context object, the transaction template in the transaction template encapsulation object is statically called to execute the transaction.

[0140] According to embodiments of this disclosure, the creation unit is further configured to create an annotation object; wherein the annotation object includes an annotation for enabling a transaction switch; create a context object; wherein the context object stores the context of the target project; obtain a transaction template based on the context object; and create a transaction template encapsulation object to encapsulate the transaction template so that the transaction template can be invoked in a static calling manner.

[0141] According to embodiments of this disclosure, the creation unit is further configured to configure the addresses of annotation objects and context objects into the extension mechanism file of the target project so as to automatically assemble annotation objects when executing transactions.

[0142] According to embodiments of this disclosure, the transaction processing apparatus further includes a determination module.

[0143] According to embodiments of this disclosure, the determination module is used to determine whether the transaction execution is successful; if the transaction execution is successful, the module submits the successful transaction execution result; and if the transaction execution fails, the module performs a transaction rollback.

[0144] Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure, or at least part of the functions of any one or more of them, can be implemented in one module. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be implemented by dividing them into multiple modules. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as hardware circuitry, such as Field Programmable Gate Arrays (FPGAs), Programmable Logic Arrays (PLAs), Systems-on-Chip, Systems-on-Substrate, Systems-on-Package, Application-Specific Integrated Circuits (ASICs), or implemented in hardware or firmware by any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as computer program modules, which, when run, can perform corresponding functions.

[0145] For example, the transaction processing apparatus 800 may include any plurality of modules among the acquisition module 810, invocation module 820, and execution module 830, which may be implemented in a single module / unit / subunit, or any one of these modules / units / subunits may be split into multiple modules / units / subunits. Alternatively, at least a portion of the functionality of one or more of these modules / units / subunits may be combined with at least a portion of the functionality of other modules / units / subunits and implemented in a single module / unit / subunit. According to embodiments of this disclosure, the transaction processing apparatus 800 may include at least a portion of the acquisition module 810, invocation module 820, and execution module 830, which may be implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, the transaction processing apparatus 800 may include at least one of the acquisition module 810, the invocation module 820, and the execution module 830, which may be at least partially implemented as a computer program module that can perform corresponding functions when the computer program module is run.

[0146] It should be noted that the transaction processing device part in the embodiments of this disclosure corresponds to the transaction processing method part in the embodiments of this disclosure. The specific description of the transaction processing device part is referred to in the transaction processing method part, and will not be repeated here.

[0147] Figure 8 A block diagram of a computer system suitable for implementing the methods described above, according to embodiments of the present disclosure, is illustrated schematically. Figure 8 The computer system shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0148] like Figure 9 As shown, a computer system 900 according to an embodiment of this disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage portion 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this disclosure.

[0149] RAM 903 stores various programs and data required for the operation of system 900. Processor 901, ROM 902, and RAM 903 are interconnected via bus 904. Processor 901 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 902 and / or RAM 903. It should be noted that the programs may also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.

[0150] According to embodiments of this disclosure, system 900 may further include an input / output (I / O) interface 905, which is also connected to bus 904. System 900 may also include one or more of the following components connected to I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. Communication section 909 performs communication processing via a network such as the Internet. Drive 910 is also connected to I / O interface 905 as needed. Removable media 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 910 as needed so that computer programs read from there are installed into storage section 908 as needed.

[0151] According to embodiments of this disclosure, the method flow according to embodiments of this disclosure can be implemented as a computer software program. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable storage medium, the computer program containing program code for performing the methods shown in the flowchart. In such embodiments, the computer program can be downloaded and installed from a network via communication section 909, and / or installed from removable medium 911. When the computer program is executed by processor 901, it performs the functions defined in the system of embodiments of this disclosure. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0152] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.

[0153] According to embodiments of this disclosure, the computer-readable storage medium can be a non-volatile computer-readable storage medium. Examples include, but are not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0154] For example, according to embodiments of this disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.

[0155] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods provided in the embodiments of this disclosure. When the computer program product is run on an electronic device, the program code is used to enable the electronic device to implement the transaction processing methods provided in the embodiments of this disclosure.

[0156] When the computer program is executed by the processor 901, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0157] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 909, and / or installed from a removable medium 911. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.

[0158] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0159] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions. Those skilled in the art will understand that the features recited in the various embodiments and / or claims of this disclosure can be combined and / or combined in various ways, even if such combinations or combinations are not expressly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure may be combined and / or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.

[0160] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.

Claims

1. A transaction processing method, comprising: creating a transaction template tool; obtaining a transaction request instruction; in response to the transaction request instruction, invoking the transaction template tool; wherein the transaction template tool is referenced in a project object model file in a target project, and is used for executing the transaction, the transaction template tool comprising an annotation object, a context object and a transaction template encapsulation object; and based on the transaction template tool, executing the transaction, wherein the creating the transaction template tool comprises: creating a project file decoupled from the target project; wherein the project file is a single project file, and the project file comprises the annotation object, the context object and the transaction template encapsulation object; and packaging the project file to generate the transaction template tool, wherein the creating the project file decoupled from the target project comprises: creating the annotation object; wherein the annotation object comprises an annotation of a transaction switch for starting the transaction; creating the context object; wherein the context object stores a context of the target project; based on the context object, obtaining a transaction template; and creating the transaction template encapsulation object for encapsulating the transaction template, so that the transaction template is invoked in a static invocation mode, wherein the static invocation mode comprises: after the target project is started, directly allocating a memory, and loading the transaction template into the memory for invoking the transaction template.

2. The method of claim 1, wherein the executing the transaction based on the transaction template tool comprises: based on the annotation object, starting the transaction switch; and based on the transaction template encapsulation object and the context object, statically invoking the transaction template in the transaction template encapsulation object for executing the transaction.

3. The method of claim 1, wherein, The creating the project file decoupled from the target project further comprises: configuring an address of the annotation object and an address of the context object into an extension mechanism file of the target project, so that the annotation object is automatically assembled when the transaction is executed.

4. The method of claim 1, further comprising: judging whether the transaction execution is successful; in a case where the transaction execution is successful, submitting a transaction execution success result; and in a case where the transaction execution fails, implementing transaction rollback.

5. A transaction processing apparatus, comprising: a creating module configured to create a transaction template tool; an obtaining module configured to obtain a transaction request instruction; an invoking module configured to, in response to the transaction request instruction, invoke the transaction template tool; wherein the transaction template tool is referenced in a project object model file in a target project, and is used for executing the transaction, the transaction template tool comprising an annotation object, a context object and a transaction template encapsulation object; and an executing module configured to, based on the transaction template tool, execute the transaction, wherein the creating module comprises: The creating unit is configured to create an engineering project file decoupled from the target engineering; the engineering project file is a single project file, and the engineering project file comprises an annotation object, a context object and a transaction template encapsulation object; and The packaging unit is configured to package the engineering project file to generate the transaction template tool, The creating of the engineering project file decoupled from the target engineering comprises: The annotation object is created; the annotation object comprises an annotation of a transaction switch for starting the transaction; The context object is created; the context object saves the context of the target engineering; The transaction template is obtained based on the context object; and The transaction template encapsulation object is created to encapsulate the transaction template, so that the transaction template is called in a static calling mode; the static calling mode comprises the following steps: after the target engineering is started, memory is directly allocated, and the transaction template is loaded into the memory to call the transaction template. 6.A computer system, comprising: one or more processors; a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1 to 4. 7.A computer readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to implement the method of any one of claims 1 to 4.

Citation Information

Patent Citations

  • Service composition-oriented declarative transaction integration method and system

    CN102073505A

  • Business transaction processing method and device, storage medium and equipment

    CN107844363A