A transaction task execution method and device

By generating task identifiers for transaction tasks and utilizing thread extension packages and interceptors, the problem of poor thread scalability is solved, thereby improving the flexibility and efficiency of task execution.

CN113110898BActive Publication Date: 2026-07-10CHINA CONSTRUCTION BANK

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA CONSTRUCTION BANK
Filing Date
2021-05-11
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

In existing technologies, threads have poor scalability and cannot flexibly handle tasks with complex logic and long transaction lines, resulting in poor task execution.

Method used

By determining the execution request of the transaction task, a task identifier corresponding to the transaction task is generated, and mechanisms such as thread extension packages and interceptors are used to realize the scalability of threads and the customization of task identifiers.

Benefits of technology

It improves the flexibility and efficiency of threads when executing tasks, supports custom task identifiers, and enhances the scalability of task execution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113110898B_ABST
    Figure CN113110898B_ABST
Patent Text Reader

Abstract

The application discloses a transaction task execution method and device, and relates to the technical field of automatic programming. A specific implementation of the method comprises the following steps: in response to an execution request of a transaction task, determining a thread used for executing the transaction task; determining whether a task identifier of the transaction task is included in the thread; when it is determined that the task identifier is not included in the thread, generating the task identifier corresponding to the transaction task in the thread; and executing the transaction task through the thread according to the task identifier. The implementation makes the thread have scalability, supports the identification of a custom task, and thus improves the flexibility of the thread when executing the task, and is more conducive to the execution of the task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of automatic programming technology, and in particular to a method and apparatus for executing transaction tasks. Background Technology

[0002] A thread is the smallest unit of computation that an operating system can schedule. It is contained within a process and is the actual unit of operation within a process. A thread is a single, sequential flow of control within a process. Multiple threads can run within a process, each executing different tasks in parallel.

[0003] However, due to the poor scalability of threads in existing technologies, when executing tasks with complex logic and long transaction lines, threads cannot freely set the corresponding identifier for the task, which makes it difficult for threads to flexibly handle such tasks and is not conducive to task execution. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a transaction task execution method and apparatus, which can determine the thread for executing the transaction task according to the execution request of the transaction task, and when the thread does not include the task identifier of the transaction task, generate a task identifier corresponding to the transaction task in the thread, and then execute the transaction task through the thread according to the task identifier, thereby making the thread scalable, supporting the customization of task identifiers, and thus improving the flexibility of the thread when executing tasks, which is more conducive to the execution of tasks.

[0005] To achieve the above objectives, according to one aspect of the present invention, a method for executing transaction tasks is provided.

[0006] A transaction task execution method according to an embodiment of the present invention includes:

[0007] In response to a transaction task execution request, determine the thread to execute the transaction task;

[0008] Determine whether the thread includes the task identifier for the transaction task;

[0009] When it is determined that the thread does not contain a task identifier, a task identifier corresponding to the transaction task is generated in the thread.

[0010] The transaction task is executed via a thread based on the task identifier.

[0011] Optionally,

[0012] Determine whether the thread includes a task identifier for a transaction task, including:

[0013] Call the thread extension package, which includes the method for determining the task identifier;

[0014] The method of determining the task identifier determines whether the thread includes the task identifier corresponding to the transaction task.

[0015] Optionally,

[0016] The method for determining the task identifier determines whether the thread includes the task identifier corresponding to the transaction task, including:

[0017] Run the method to determine the task identifier and obtain the return value;

[0018] If the return value is in the wrong format or is empty, it is determined that the thread does not contain the task identifier corresponding to the transaction task.

[0019] If the return value is in the correct format and is not empty, then the thread is confirmed to include the task identifier corresponding to the transaction task.

[0020] Optionally,

[0021] When it is determined that the thread does not contain a task identifier, a task identifier corresponding to the transaction task is generated in the thread, including:

[0022] By determining the method of task identification, a task identifier corresponding to the transaction task is generated in the thread.

[0023] Optionally,

[0024] The thread extension package also includes one or more of the following methods: the method for determining the sub-transaction sequence number corresponding to the task identifier, the method for determining the first type of transaction task, and the method for replacing the task identifier.

[0025] Optionally,

[0026] When a transaction task includes multiple sub-transaction tasks, a task identifier corresponding to the transaction task is generated in the thread, including:

[0027] Determine the second type of each of the multiple sub-transaction tasks;

[0028] Based on the second type of multiple sub-transaction tasks, sub-task identifiers corresponding to multiple sub-transaction tasks are generated respectively; among them, sub-transaction tasks of the same second type correspond to the same sub-task identifier, and sub-transaction tasks of different second types correspond to different sub-task identifiers.

[0029] Optionally,

[0030] When a transaction task includes multiple sub-transaction tasks of the same second type, the multiple sub-transaction tasks of the same second type correspond to multiple different sub-transaction sequence numbers.

[0031] Optionally,

[0032] The execution request includes a first request message;

[0033] Executing transaction tasks via threads includes:

[0034] Establish a swap space in the thread and cache the first request message in the swap space;

[0035] Determine the first type of transaction task;

[0036] When the first type of transaction task is an online transaction, a first interface call request is generated according to the first call object indicated by the first request message cached in the exchange area;

[0037] The first interface is used to call the first calling object, so that the first calling object can execute the transaction task.

[0038] Optionally,

[0039] The switching area also caches preset second message information;

[0040] When the first type of transaction task is an online transaction, a first interface call request is generated based on the first request message and the second message information cached in the exchange area.

[0041] Optionally,

[0042] When the first type of transaction task is an active transaction, a second interface call request is generated based on the preset second message information cached in the exchange area;

[0043] The second interface is used to request and invoke the second invocation object, so that the second invocation object can execute the transaction task.

[0044] Optionally,

[0045] The second message information includes any one or more of the following: organization number, task identifier, sub-transaction number, service type, operator number, channel number, and channel code.

[0046] Optionally,

[0047] The execution request also includes public domain information;

[0048] Executing transaction tasks via threads includes:

[0049] Determine whether the content of the first request message and / or public domain information is correct;

[0050] If not, intercept the execution request and return a message indicating that the content of the first request message and / or public domain information is incorrect.

[0051] Optionally,

[0052] Interceptors are used to intercept execution requests.

[0053] Optionally,

[0054] The interceptor can be any of the following: AOP interceptor, Interceptor interceptor, or Filter interceptor.

[0055] Optionally,

[0056] The ThreadLocal method is used to manage task identifiers in threads.

[0057] To achieve the above objectives, according to another aspect of the present invention, a transaction task execution apparatus is provided.

[0058] An embodiment of the present invention provides a transaction task execution device comprising a response module, a task identifier determination module, a task identifier generation module, and an execution module; wherein:

[0059] The response module is used to respond to the execution request of a transaction task and determine the thread to execute the transaction task;

[0060] The task identifier determination module is used to determine whether a thread includes a task identifier for a transaction task.

[0061] The task identifier generation module is used to generate a task identifier corresponding to the transaction task in the thread when it is determined that the thread does not contain a task identifier.

[0062] The execution module is used to execute transaction tasks via threads based on task identifiers.

[0063] To achieve the above objectives, according to another aspect of the present invention, an electronic device for executing transaction tasks is provided.

[0064] An electronic device for executing transaction tasks according to an embodiment of the present invention includes: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement a transaction task execution method according to an embodiment of the present invention.

[0065] To achieve the above objectives, according to another aspect of the present invention, a computer-readable storage medium is provided.

[0066] An embodiment of the present invention provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a transaction task execution method according to an embodiment of the present invention.

[0067] One embodiment of the above invention has the following advantages or beneficial effects: it can determine the thread to execute the transaction task according to the execution request of the transaction task, and when the thread does not include the task identifier of the transaction task, it generates a task identifier corresponding to the transaction task in the thread, and then executes the transaction task through the thread according to the task identifier, thereby making the thread scalable, supporting the identification of custom tasks, thereby improving the flexibility of the thread when executing tasks, and making it more conducive to the execution of tasks.

[0068] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description

[0069] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:

[0070] Figure 1 This is a schematic diagram of the main steps of a transaction task execution method according to an embodiment of the present invention;

[0071] Figure 2 This is a schematic diagram illustrating the main steps of a method for executing transaction tasks via threads according to an embodiment of the present invention;

[0072] Figure 3 This is a schematic diagram of the main modules of a transaction task execution device according to an embodiment of the present invention;

[0073] Figure 4 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;

[0074] Figure 5 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation

[0075] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0076] It should be noted that, unless otherwise specified, the embodiments of the present invention and the technical features thereof can be combined with each other.

[0077] Figure 1 This is a schematic diagram illustrating the main steps of a transaction task execution method according to an embodiment of the present invention.

[0078] like Figure 1 As shown, a transaction task execution method according to an embodiment of the present invention mainly includes the following steps:

[0079] Step S101: In response to the execution request of the transaction task, determine the thread to be used to execute the transaction task.

[0080] In this embodiment of the invention, the first type of transaction task can be an online transaction or an active transaction. The execution request of the transaction task may include a first request message and / or public domain information, and the thread may include an exchange area for caching the first request message and / or public domain information.

[0081] Step S102: Determine whether the thread includes the task identifier of the transaction task.

[0082] In this embodiment of the invention, a thread extension package can be used to determine whether a thread includes a task identifier for a transaction task. Specifically, the thread extension package can be invoked, and the method for determining task identifiers within the thread extension package can be used to determine whether the thread includes a task identifier corresponding to a transaction task.

[0083] In this embodiment of the invention, the task identifier is the global tracking number corresponding to the transaction task, and the global tracking number is a unique identifier for a transaction throughout its execution. In a preferred embodiment of the invention, the ThreadLocal method can be used to manage the task identifiers in a thread.

[0084] In this embodiment of the invention, in addition to the method of determining the task identifier, the thread extension package also includes any one or more of the following methods: the method of determining the sub-transaction sequence number corresponding to the task identifier, the method of determining the first type of transaction task, and the method of replacing the task identifier.

[0085] In a preferred embodiment of the present invention, the task identifier encapsulated in the thread extension package is determined by the getCurrentSysEvtTraceId method, the sub-transaction sequence number corresponding to the task identifier is determined by the getNextSysSndSerialNo, calcNextSysSndSerialNo, getNextSysSndSerialNo, and calcNextSysSndSerialNo methods, the first type of transaction task is determined by the isOnlineCall method, and the task identifier is replaced by the getNewSysEvtTraceId method.

[0086] Specifically, the parameters required for the above method, the corresponding functions, and the precautions for using the above method are shown in Table 1:

[0087]

[0088] Table 1

[0089] The method shown in Table 1 allows for the free setting and reading of the global tracking number and sub-transaction sequence number, and supports scenarios involving multiple switching between online and active trading. Furthermore, the ThreadLocal method can be used to manage the global tracking number and sub-transaction sequence number within a thread, and record the switching of the global tracking number in each transaction.

[0090] In this embodiment of the invention, the process of determining whether a thread includes a task identifier corresponding to a transaction task by determining the task identifier may specifically include: running a task identifier determination method to obtain a return value; when the return value is in the wrong format or the return value is empty, determining that the thread does not include a task identifier corresponding to a transaction task; when the return value is in the right format and the return value is not empty, determining that the thread includes a task identifier corresponding to a transaction task.

[0091] In this embodiment of the invention, the thread extension package may further include a custom method for global variables. This custom method allows for the setting and retrieval of global variables available within the thread throughout its entire lifecycle, further increasing the thread's scalability and flexibility. These global variables can be stored in a thread-wide global collection for developers to use at any time.

[0092] In a preferred embodiment of the present invention, the customizable methods for global variables encapsulated in the thread extension package may include the setGlobalProperty method, the getGlobalProperty method, and the isGlobalPropertyExist method.

[0093] Specifically, the parameters required for the above method and the corresponding functions are shown in Table 2:

[0094] Way parameter Function setGlobalPropetry String property; Object value Set the value of a global variable getGlobalProperty String property Get the value of a global variable isGlobalPropertyExist String property Determine if a global variable exists

[0095] Table 2

[0096] Step S103: When it is determined that the thread does not contain a task identifier, generate a task identifier corresponding to the transaction task in the thread.

[0097] In this embodiment of the invention, when it is determined that the thread does not contain a task identifier, a task identifier corresponding to the transaction task can be generated in the thread through the task identifier determination method. As shown in Table 1, the function of the getCurrentSysEvtTraceId method shows that the current global trace number can be obtained through this method, and if the current global trace number does not exist, a new global trace number can be generated.

[0098] In this embodiment of the invention, when a transaction task includes multiple sub-transaction tasks, the process of generating a task identifier corresponding to the transaction task in a thread includes: determining a second type of each of the multiple sub-transaction tasks; generating a sub-task identifier corresponding to each of the multiple sub-transaction tasks according to the second type of each of the multiple sub-transaction tasks; wherein, sub-transaction tasks of the same second type correspond to the same sub-task identifier, and sub-transaction tasks of different second types correspond to different sub-task identifiers.

[0099] For example, when a transaction task includes both sub-transactions of type 2 (transfer) and sub-transactions of type 2 (query), a sub-task identifier "Transfer" can be generated for the transfer sub-transaction task, and a sub-task identifier "Inquire" can be generated for the query sub-transaction task. The global tracking number corresponding to the transfer sub-transaction task and the query sub-transaction task is the same, indicating that they belong to the same transaction task.

[0100] In this embodiment of the invention, when a transaction task includes multiple sub-transaction tasks of the same second type, the multiple sub-transaction tasks of the same second type correspond to multiple different sub-transaction sequence numbers.

[0101] For example, when a transaction task includes five sub-transfer transactions, the sub-task identifier for all five sub-transfer transactions is "Transfer," and their sub-transaction numbers are sequentially incremented, such as 00, 01, 02, 03, and 04. This scheme does not impose specific restrictions on the counting method for sub-transaction numbers.

[0102] Step S104: Execute the transaction task through a thread according to the task identifier.

[0103] In this embodiment of the invention, when a thread is executing other transaction tasks, upon receiving a transaction task to be executed, the thread can switch to execute the received transaction task based on its global tracking number. Furthermore, the thread can switch between different transaction tasks multiple times based on their global tracking numbers, improving the flexibility of the thread when executing transaction tasks.

[0104] In this embodiment of the invention, the execution request may include a first request message; a method for executing a transaction task through a thread is as follows: Figure 2 As shown, the method mainly includes the following steps:

[0105] Step S201: Establish a swap area in the thread and cache the first request message in the swap area;

[0106] Step S202: Determine the first type of transaction task;

[0107] Step S203: When the first type of transaction task is online transaction, generate a first interface call request according to the first call object indicated by the first request message cached in the exchange area;

[0108] Step S204: Invoke the first calling object through the first interface call request so that the first calling object can execute the transaction task.

[0109] In this embodiment of the invention, the exchange area may also cache a preset second message information; when the first type of transaction task is an online transaction, a first interface call request can be generated based on the first request message and the second message information cached in the exchange area. Thus, when the first message information is incomplete, it can be completed based on the second message information before generating the first interface call request, thereby improving the efficiency of the thread in executing the transaction task.

[0110] In this embodiment of the invention, when the first type of transaction task is an active transaction, it indicates that the transaction task is actively initiated by the system where the thread resides, so its execution request may not include the first message information. At this time, a second interface call request can be generated based on the preset second message information cached in the exchange area; the second call object is called through the second interface call request so that the second call object executes the transaction task.

[0111] In this embodiment of the invention, the second message information includes any one or more of the following: organization number, task identifier, sub-transaction sequence number, service type, operator number, channel number, and channel code.

[0112] The correspondence between the above content and its attribute names in the second message information is shown in Table 3:

[0113]

[0114]

[0115] Table 3

[0116] In this embodiment of the invention, developers can also manually set other content included in the second message information according to specific needs to further increase the scalability and flexibility of the thread.

[0117] In this embodiment of the invention, the execution request may further include public domain information; the process of executing the transaction task through a thread includes: determining whether the content of the first request message and / or the public domain information is correct; if not, intercepting the execution request and returning a prompt message that the content of the first request message and / or the public domain information is incorrect.

[0118] In this embodiment of the invention, an interceptor can be used to intercept execution requests.

[0119] In this embodiment of the invention, the interceptor can also be used to intercept execution requests that require preprocessing of the first request message and / or public domain information. For example, when performing a transfer transaction task, if the transfer transaction task is an online transaction and a specified institution number and teller number are set in the execution request, the thread will cache the specified institution number and teller number in the exchange area, and use the specified institution number and teller number when generating the first interface call request, instead of directly using the values ​​pre-saved in the public domain information of the exchange area; after the first call object is completed, the thread restores the values ​​pre-saved in the public domain information of the exchange area.

[0120] In this embodiment of the invention, the interceptor is any one of the following: AOP interceptor, Interceptor interceptor, or Filter interceptor.

[0121] According to an embodiment of the present invention, a transaction task execution method can determine the thread for executing the transaction task based on the execution request of the transaction task. When the thread does not include the task identifier of the transaction task, a task identifier corresponding to the transaction task is generated in the thread. Then, the transaction task is executed by the thread according to the task identifier. This makes the thread scalable, supports the identification of custom tasks, and improves the flexibility of the thread when executing tasks, which is more conducive to the execution of tasks.

[0122] Figure 3 This is a schematic diagram of the main modules of a transaction task execution device according to an embodiment of the present invention.

[0123] like Figure 3 As shown, a transaction task execution device 300 according to an embodiment of the present invention includes a response module 301, a task identifier determination module 302, a task identifier generation module 303, and an execution module 304; wherein:

[0124] The response module 301 is used to determine the thread to execute the transaction task in response to the execution request of the transaction task;

[0125] The task identifier determination module 302 is used to determine whether the thread includes a task identifier for a transaction task.

[0126] The task identifier generation module 303 is used to generate a task identifier corresponding to the transaction task in the thread when it is determined that the thread does not contain a task identifier.

[0127] Execution module 304 is used to execute transaction tasks via threads based on task identifiers.

[0128] In this embodiment of the invention, the task identifier determination module 302 is further configured to: call the thread extension package, which includes a method for determining the task identifier; and determine whether the thread includes a task identifier corresponding to the transaction task by using the method for determining the task identifier.

[0129] In this embodiment of the invention, the task identifier determination module 302 is further configured to: run the task identifier determination method to obtain a return value; when the return value is in the wrong format or the return value is empty, determine that the task identifier corresponding to the transaction task is not included in the thread; when the return value is in the correct format and the return value is not empty, determine that the task identifier corresponding to the transaction task is included in the thread.

[0130] In this embodiment of the invention, the task identifier generation module 303 is further configured to: generate a task identifier corresponding to the transaction task in the thread by determining the task identifier.

[0131] In this embodiment of the invention, the thread extension package further includes any one or more of the following methods: the method for determining the sub-transaction sequence number corresponding to the task identifier, the method for determining the first type of transaction task, and the method for replacing the task identifier.

[0132] In this embodiment of the invention, when a transaction task includes multiple sub-transaction tasks, the task identifier generation module 303 is further configured to: determine the second type of the multiple sub-transaction tasks respectively; generate sub-task identifiers corresponding to the multiple sub-transaction tasks according to the second type of the multiple sub-transaction tasks respectively; wherein, sub-transaction tasks of the same second type correspond to the same sub-task identifier, and sub-transaction tasks of different second types correspond to different sub-task identifiers.

[0133] In this embodiment of the invention, when a transaction task includes multiple sub-transaction tasks of the same second type, the multiple sub-transaction tasks of the same second type correspond to multiple different sub-transaction sequence numbers.

[0134] In this embodiment of the invention, the execution request includes a first request message; the execution module 304 is further configured to: establish an exchange area in a thread and cache the first request message in the exchange area; determine a first type of transaction task; when the first type of transaction task is an online transaction, generate a first interface call request according to the first call object indicated by the first request message cached in the exchange area; and call the first call object through the first interface call request so that the first call object executes the transaction task.

[0135] In this embodiment of the invention, the exchange area also caches a preset second message information; the execution module 304 is further configured to: when the first type of transaction task is an online transaction, generate a first interface call request based on the first request message and the second message information cached in the exchange area.

[0136] In this embodiment of the invention, the execution module 304 is further configured to: when the first type of transaction task is an active transaction, generate a second interface call request based on the preset second message information cached in the exchange area; and call a second call object through the second interface call request so that the second call object executes the transaction task.

[0137] In this embodiment of the invention, the second message information includes any one or more of the following: organization number, task identifier, sub-transaction sequence number, service type, operator number, channel number, and channel code.

[0138] In this embodiment of the invention, the execution request also includes public domain information; the execution module 304 is further configured to: determine whether the content of the first request message and / or the public domain information is correct; if not, intercept the execution request and return a prompt message indicating that the content of the first request message and / or the public domain information is incorrect.

[0139] In this embodiment of the invention, the execution module 304 is further configured to: intercept the execution request through an interceptor.

[0140] In this embodiment of the invention, the interceptor is any one of the following: AOP interceptor, Interceptor interceptor, or Filter interceptor.

[0141] In this embodiment of the invention, the execution module 304 is further configured to: manage the task identifiers in the thread using the ThreadLocal method.

[0142] According to an embodiment of the present invention, a transaction task execution device can determine the thread for executing the transaction task based on the execution request of the transaction task. When the thread does not include the task identifier of the transaction task, a task identifier corresponding to the transaction task is generated in the thread. Then, the transaction task is executed by the thread according to the task identifier, thereby making the thread scalable, supporting the identification of custom tasks, and thus improving the flexibility of the thread when executing tasks, which is more conducive to the execution of tasks.

[0143] Figure 4 An exemplary system architecture 400 is shown, which can be applied to a transaction task execution method or a transaction task execution device according to embodiments of the present invention.

[0144] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, and 403, a network 404, and electronic devices 405. Network 404 serves as the medium for providing communication links between terminal devices 401, 402, and 403 and electronic devices 405. Network 404 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.

[0145] Users can use terminal devices 401, 402, and 403 to interact with electronic device 405 via network 404 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 401, 402, and 403, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc.

[0146] Terminal devices 401, 402, and 403 can be various electronic devices with displays that support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0147] Electronic device 405 can be a server providing various services, such as a backend management server supporting shopping websites browsed by users using terminal devices 401, 402, and 403. The backend management server can analyze and process data such as received product information query requests, and feed back the processing results (such as target push information and product information) to the terminal devices.

[0148] It should be noted that the transaction task execution method provided in this embodiment of the invention is generally executed by electronic device 405, and correspondingly, a transaction task execution device is generally disposed in electronic device 405.

[0149] It should be understood that Figure 4 The number of terminal devices, networks, and electronic devices shown is merely illustrative. Any number of terminal devices, networks, and electronic devices can be included depending on implementation needs.

[0150] The following is for reference. Figure 5 It shows a schematic diagram of the structure of a computer system 500 suitable for implementing a terminal device of the present invention. Figure 5 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0151] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 502 or programs loaded from storage section 508 into random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of the system 500. The CPU 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0152] The following components are connected to I / O interface 505: an input section 506 including a keyboard, mouse, etc.; an output section 507 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to I / O interface 505 as needed. A removable medium 511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 510 as needed so that computer programs read from it can be installed into storage section 508 as needed.

[0153] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 509, and / or installed from removable medium 511. When the computer program is executed by central processing unit (CPU) 501, it performs the functions defined above in the system of this invention.

[0154] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0155] 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 invention. 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.

[0156] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor can be described as including a response module, a task identifier determination module, a task identifier generation module, and an execution module. The names of these modules do not necessarily limit the module itself; for example, the response module can also be described as "a module that determines the thread for executing the transaction task in response to an execution request of the transaction task."

[0157] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, cause the device to include: in response to an execution request for a transaction task, determining a thread for executing the transaction task; determining whether the thread includes a task identifier for the transaction task; when it is determined that the thread does not include a task identifier, generating a task identifier corresponding to the transaction task in the thread; and executing the transaction task through the thread according to the task identifier.

[0158] According to the technical solution of the present invention, a thread for executing a transaction task can be determined based on the execution request of the transaction task. When the thread does not include the task identifier of the transaction task, a task identifier corresponding to the transaction task is generated in the thread. Then, the transaction task is executed by the thread according to the task identifier, thereby making the thread scalable, supporting the identification of custom tasks, and thus improving the flexibility of the thread when executing tasks, which is more conducive to the execution of tasks.

[0159] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for executing a transaction task, characterized in that, include: In response to a request to execute a transaction task, a thread is determined to execute the transaction task. The thread extension package is invoked, which includes a method for determining the task identifier. Based on this method, it is determined whether the thread contains a task identifier corresponding to the transaction task. The method for determining the task identifier encapsulated in the thread extension package is the `getCurrentSysEvtTraceId` method. The thread extension package also includes any one or more of the following methods: a method for determining the sub-transaction sequence number corresponding to the task identifier, a method for determining the first type of the transaction task, and a method for replacing the task identifier. The method for determining the sub-transaction sequence number corresponding to the task identifier is `getNextSysSndSerialNo` and `calcNextSysSndSerialNo`, the method for determining the first type of the transaction task is `isOnlineCall`, and the method for replacing the task identifier is `getNewSysEvtTraceId`. The function of getCurrentSysEvtTraceId is to obtain the current global trace number; The function of getNextSysSndSerialNo is to obtain the next sub-transaction sequence number of the current global tracking number and update the swap area; or, if the input is a specified global tracking number, to obtain the next sub-transaction sequence number of the specified global tracking number and update the swap area. The function of calcNextSysSndSerialNo is to calculate the next sub-transaction number of the current global tracking number without updating the swap area; or, if the input is a specified global tracking number, to calculate the next sub-transaction number of the specified global tracking number without updating the swap area. The isOnlineCall function is used to determine whether the received transaction task is an online transaction; or, if the input is a specified global tracking number, it determines whether the transaction task being executed by the current thread is an online transaction or an active transaction based on the specified global tracking number. The getNewSysEvtTraceId function is to obtain a new global trace number to replace the current global trace number and set a custom swap area; When it is determined that the thread does not include the task identifier, the task identifier corresponding to the transaction task is generated in the thread; The transaction task is executed through the thread according to the task identifier; When the transaction task includes multiple sub-transaction tasks, generating the task identifier corresponding to the transaction task in the thread includes: The second type of each of the multiple sub-transaction tasks is determined; Based on the second type of the plurality of sub-transaction tasks, sub-task identifiers corresponding to the plurality of sub-transaction tasks are generated respectively; wherein, sub-transaction tasks of the same second type correspond to the same sub-task identifier, and sub-transaction tasks of different second types correspond to different sub-task identifiers. When the transaction task includes multiple sub-transaction tasks of the same second type, the multiple sub-transaction tasks of the same second type correspond to multiple different sub-transaction sequence numbers.

2. The method according to claim 1, characterized in that, The step of determining whether the thread includes the task identifier corresponding to the transaction task through the method of determining the task identifier includes: Run the method for determining the task identifier and obtain the return value; When the return value is in the wrong format or the return value is empty, it is determined that the thread does not include the task identifier corresponding to the transaction task; When the return value is in the correct format and is not empty, it is determined that the thread includes the task identifier corresponding to the transaction task.

3. The method according to claim 1, characterized in that, When it is determined that the thread does not include the task identifier, the step of generating a task identifier corresponding to the transaction task in the thread includes: The task identifier corresponding to the transaction task is generated in the thread using the method described above.

4. The method according to claim 1, characterized in that, The execution request includes a first request message; The execution of the transaction task through the thread includes: A swap area is established in the thread, and the first request message is cached in the swap area; Determine the first type of the transaction task; When the first type of the transaction task is an online transaction, a first interface call request is generated according to the first calling object indicated by the first request message cached in the exchange area; The first interface call request invokes the first calling object, so that the first calling object executes the transaction task.

5. The method according to claim 4, characterized in that, The exchange area also caches preset second message information; When the first type of the transaction task is an online transaction, the first interface call request is generated based on the first request message and the second message information cached in the exchange area.

6. The method according to claim 5, characterized in that, When the first type of the transaction task is an active transaction, a second interface call request is generated based on the preset second message information cached in the exchange area; The second interface is used to request and invoke the second invocation object, so that the second invocation object can execute the transaction task.

7. The method according to claim 5, characterized in that, The second message information includes any one or more of the following: organization number, task identifier, sub-transaction number, service type, operator number, channel number, and channel code.

8. The method according to claim 4, characterized in that, The execution request also includes public domain information; The execution of the transaction task through the thread includes: Determine whether the content of the first request message and / or the public domain information is correct; If not, intercept the execution request and return a message indicating that the content of the first request message and / or the public domain information is incorrect.

9. The method according to claim 8, characterized in that, The execution request is intercepted using an interceptor.

10. The method according to claim 9, characterized in that, The interceptor can be any of the following: AOP interceptor, Interceptor interceptor, or Filter interceptor.

11. The method according to any one of claims 1-10, characterized in that, Also includes: The task identifier in the thread is managed using the ThreadLocal method.

12. A transaction task execution device, characterized in that, It includes a response module, a task identifier determination module, a task identifier generation module, and an execution module; among which: The response module is used to determine the thread for executing the transaction task in response to the execution request of the transaction task; The task identifier determination module is used to call a thread extension package, which includes a method for determining task identifiers. The method for determining task identifiers determines whether the thread includes a task identifier corresponding to the transaction task. The method for determining the task identifier encapsulated in the thread extension package is the `getCurrentSysEvtTraceId` method. The thread extension package also includes any one or more of the following methods: a method for determining the sub-transaction sequence number corresponding to the task identifier, a method for determining the first type of the transaction task, and a method for replacing the task identifier. The method for determining the sub-transaction sequence number corresponding to the task identifier is `getNextSysSndSerialNo` and `calcNextSysSndSerialNo`, the method for determining the first type of the transaction task is `isOnlineCall`, and the method for replacing the task identifier is `getNewSysEvtTraceId`. The function of getCurrentSysEvtTraceId is to obtain the current global trace number; The function of getNextSysSndSerialNo is to obtain the next sub-transaction sequence number of the current global tracking number and update the swap area; or, if the input is a specified global tracking number, to obtain the next sub-transaction sequence number of the specified global tracking number and update the swap area. The function of calcNextSysSndSerialNo is to calculate the next sub-transaction number of the current global tracking number without updating the swap area; or, if the input is a specified global tracking number, to calculate the next sub-transaction number of the specified global tracking number without updating the swap area. The isOnlineCall function is used to determine whether the received transaction task is an online transaction; or, if the input is a specified global tracking number, it determines whether the transaction task being executed by the current thread is an online transaction or an active transaction based on the specified global tracking number. The getNewSysEvtTraceId function is to obtain a new global trace number to replace the current global trace number and set a custom swap area; The task identifier generation module is used to generate the task identifier corresponding to the transaction task in the thread when it is determined that the thread does not contain the task identifier. The execution module is used to execute the transaction task through the thread according to the task identifier; When the transaction task includes multiple sub-transaction tasks, the task identifier generation module is further used for: The second type of each of the multiple sub-transaction tasks is determined; Based on the second type of the plurality of sub-transaction tasks, sub-task identifiers corresponding to the plurality of sub-transaction tasks are generated respectively; wherein, sub-transaction tasks of the same second type correspond to the same sub-task identifier, and sub-transaction tasks of different second types correspond to different sub-task identifiers. When the transaction task includes multiple sub-transaction tasks of the same second type, the multiple sub-transaction tasks of the same second type correspond to multiple different sub-transaction sequence numbers.

13. An electronic device for executing transaction tasks, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-11.

14. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-11.