Transaction task delay method based on time wheel and related equipment

By adding delay tasks to the time round, the performance problems caused by the execution of online transaction timing tasks are solved, efficient and automatic task scheduling and execution are achieved, and system performance and reliability are improved.

CN119919214APending Publication Date: 2025-05-02SHENZHEN YISHIHUOLALA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411998531.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

In business scenarios involving online transactions, the execution of timed tasks is likely to lead to performance problems, such as confusion of code, high number of tasks concurrency resulting in low number of queries, and blocking thread pools for tasks.

Method used

The time-round trading task delay method is used to add the delay task to the preset time round, and the task is executed when the pointer of the time round triggers the task.

Benefits of technology

Improve task execution efficiency, avoid resource consumption in traditional database scanning methods, and automatically schedule tasks according to preset time without manual intervention, simplify task management processes, ensure accurate task execution, avoid delays or omissions, and improve system performance and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919214A_ABST
    Figure CN119919214A_ABST
Patent Text Reader

Abstract

The embodiment of the invention belongs to the field of data processing, and relates to a transaction task delay method based on a time wheel, comprising the following steps: acquiring a delay transaction demand corresponding to a target business item; according to the delay transaction demand, generating a delay task and adding the delay task to the target business item; when the delay task is executed, placing an unexecuted task of the target business item into a preset time wheel; and when the pointer of the time wheel triggers the unexecuted task, executing the unexecuted task. The invention further provides a transaction task delay device based on the time wheel, computer equipment and a storage medium. According to the method, the delay task is added into the time wheel, so that the task execution efficiency is improved, a traditional database scanning mode is avoided, resource consumption is reduced, the task is automatically scheduled according to the preset time, the task management process is simplified, accurate execution of the task is ensured, delay or omission is avoided, and the performance and reliability of the system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and is applied to business scenarios involving online transactions, and in particular to a transaction task delay method based on a time wheel and related equipment. Background Art

[0002] There are usually various scheduled tasks in business projects involving online transactions, which require scanning the database at a specified time. However, this approach is prone to serious performance problems, such as code chaos that cannot be effectively managed and monitored, high concurrency in task scenarios resulting in low queries per second, and some tasks blocking the thread pool that prevents other tasks from consuming. Summary of the invention

[0003] The purpose of the embodiments of the present application is to propose a transaction task delay method based on a time wheel and related equipment, aiming to avoid serious performance problems when executing scheduled tasks of online transactions.

[0004] In order to solve the above technical problems, the embodiment of the present application provides a transaction task delay method based on a time wheel, which adopts the following technical solution:

[0005] A transaction task delay method based on a time wheel comprises the following steps:

[0006] Obtain the delayed transaction requirements corresponding to the target business project;

[0007] According to the delayed transaction requirement, generating a delayed task and adding the delayed task to the target business item;

[0008] When the delayed task is executed, the unexecuted tasks of the target business project are placed into a preset time wheel;

[0009] When the pointer of the time wheel triggers the unexecuted task, the unexecuted task is executed.

[0010] Furthermore, when the delayed task is executed, the step of placing the unexecuted tasks of the target business project into a preset time wheel specifically includes:

[0011] According to the delayed task, determining a target slot in the time queue corresponding to the time wheel;

[0012] The unexecuted task is placed into the target slot.

[0013] Further, after the step of placing the unexecuted task into the target slot, the method further includes:

[0014] If the pointer points to the target slot, the unexecuted task is set to a triggered state, and a thread is started to execute the unexecuted task.

[0015] Furthermore, the step of generating a delayed task according to the delayed transaction requirement and adding the delayed task to the target business item specifically includes:

[0016] Receive a task creation instruction carrying configuration information, configure the delayed transaction requirement according to the configuration information, and obtain a JAR file corresponding to the delayed task;

[0017] Integrate the JAR file into the target business project.

[0018] Furthermore, the delayed transaction requirement includes extension time information. After the step of generating a delayed task according to the delayed transaction requirement and adding the delayed task to the target business item, the step further includes:

[0019] Compare the extended time information with the preset input time corresponding to the time wheel to determine whether the extended time of the delayed task is greater than the preset input time;

[0020] If the extended time is less than or equal to the preset insertion time, the process of placing the unexecuted task into the time wheel is not performed.

[0021] Further, after the step of executing the unexecuted task when the pointer of the time wheel triggers the unexecuted task, the method further includes:

[0022] Obtaining the execution result corresponding to the unexecuted task;

[0023] Analyze the execution result to determine whether there is an abnormal task;

[0024] If the abnormal task exists, return to execute the abnormal task.

[0025] Furthermore, it is characterized in that after the step of placing the unexecuted tasks of the target business project into a preset time wheel when the delayed task is executed, it also includes:

[0026] Display the fuse button corresponding to the delayed task on the preset interface;

[0027] When the fuse button is triggered, the thread is started to execute the unexecuted task.

[0028] In order to solve the above technical problems, the embodiment of the present application further provides a transaction task delay device based on a time wheel, which adopts the following technical solution:

[0029] A transaction task delay device based on a time wheel, comprising:

[0030] An acquisition module is used to obtain the delayed transaction requirements corresponding to the target business project;

[0031] A generating module, used for generating a delayed task according to the delayed transaction requirement and adding the delayed task to the target business item;

[0032] An inserting module, used for inserting the unexecuted tasks of the target business project into a preset time wheel when the delayed task is executed;

[0033] An execution module is used to execute the unexecuted task when the pointer of the time wheel triggers the unexecuted task.

[0034] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0035] A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the transaction task delay method based on the time wheel as described above are implemented.

[0036] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0037] A computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the transaction task delay method based on a time wheel as described above.

[0038] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0039] The transaction task delay method based on the time wheel disclosed in the present application obtains the delayed transaction demand corresponding to the target business project; generates a delayed task according to the delayed transaction demand and adds the delayed task to the target business project; when the delayed task is executed, the unexecuted task of the target business project is placed in a preset time wheel; when the pointer of the time wheel triggers the unexecuted task, the unexecuted task is executed. The present application improves the task execution efficiency by adding the delayed task to the time wheel, avoids the traditional database scanning method, thereby reducing resource consumption, and automatically schedules the task according to the preset time without manual intervention, simplifies the task management process, and ensures the accurate execution of the task, avoids delays or omissions, and improves the performance and reliability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0041] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0042] Figure 2 is a flow chart of an embodiment of a transaction task delay method based on a time wheel according to the present application;

[0043] Figure 3 It is a structural schematic diagram of an embodiment of a transaction task delay device based on a time wheel according to the present application;

[0044] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION

[0045] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0046] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0047] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0048] like Figure 1As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0049] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0050] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 (Moving Picture Experts Group Audio Layer III) players, MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.

[0051] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0052] It should be noted that the transaction task delay method based on the time wheel provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the transaction task delay device based on the time wheel is generally arranged in the server / terminal device.

[0053] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0054] Continue to refer Figure 2 , shows a flow chart of an embodiment of a transaction task delay method based on a time wheel according to the present application. The transaction task delay method based on a time wheel comprises the following steps:

[0055] Step S201, obtaining the delayed transaction requirements corresponding to the target business item.

[0056] In this embodiment, the transaction task delay method based on the time wheel is run on the electronic device (for example Figure 1 The server / terminal device shown in the figure can send or receive data through a wired connection or a wireless connection. It should be noted that the above wireless connection methods may include but are not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0057] In this embodiment, each business project may have some delayed execution requirements, such as order processing, payment confirmation, data synchronization, etc. These requirements usually include the time required for delayed execution and the specific content of the task itself. For example, in an e-commerce platform, after a user places an order, the system may need to wait for a period of time (such as 30 minutes) to execute the payment confirmation task. This delay is the delayed transaction requirement of the business project.

[0058] Step S202: Generate a delayed task according to the delayed transaction requirement and add the delayed task to the target business item.

[0059] In this embodiment, once the delay requirements are determined, the system will create corresponding delay tasks based on these requirements. These tasks will be executed at a predetermined time point and bound to specific business items so that they can be correctly associated when executed. If the order payment confirmation needs to be delayed for 30 minutes, the system will create an "order payment confirmation" task and specify a delay time of 30 minutes. This task will be added to the business process of the order.

[0060] Step S203: When the delayed task is executed, the unexecuted tasks of the target business project are placed into a preset time wheel.

[0061] In this embodiment, the time wheel is an efficient timed task scheduling algorithm for processing a large number of delayed tasks. When the delayed tasks are executed, these tasks are placed in a preset time wheel, so that the time wheel can be triggered and execute the tasks at the set time. In the e-commerce platform, if the system wants to execute a "payment confirmation task", when the task is about to be triggered, the system will put it into the time wheel, and the pointer of the time wheel will continue to rotate. Whenever the pointer reaches the execution time required for the task, the execution of the corresponding task will be triggered.

[0062] Step S204: when the pointer of the time wheel triggers the unexecuted task, the unexecuted task is executed.

[0063] In this embodiment, the pointer of the time wheel moves according to the set time interval. Every time it reaches a preset time point, it will trigger and execute the corresponding task. Once the task is triggered, the system will call the corresponding business logic to complete the execution of the task. Assuming that a task is triggered after 30 minutes, when the pointer of the time wheel reaches the position of the task after 30 minutes, the system will execute the callback logic of the task, such as confirming payment, delivery, etc.

[0064] It should be noted that if some delayed tasks are more urgent than other tasks, different priorities can be set for these tasks on the time wheel. The time wheel can adjust the execution order of tasks according to the priority of the tasks to ensure that high-priority tasks are executed first. Assuming that the payment confirmation task in the platform is more urgent than the data synchronization task, a higher priority can be set for the payment confirmation task in the time wheel to ensure that it can be executed faster. Before or during the execution of a task, the delayed execution time of the task can be dynamically adjusted according to real-time business needs. For example, in some business scenarios, users may request to modify the delayed execution time, and the payment time of an order may be extended by the user. If the payment is still not completed, the user can request the system to extend the delay time of the payment confirmation task by 30 minutes.

[0065] This application improves the efficiency of task execution by adding delayed tasks to the time wheel, avoids the traditional database scanning method, and thus reduces resource consumption. Tasks are automatically scheduled according to preset times without human intervention, which simplifies the task management process and ensures the accurate execution of tasks, avoiding delays or omissions, and improving the performance and reliability of the system.

[0066] In some optional implementations of this embodiment, the step of placing the unexecuted tasks of the target business project into a preset time wheel when the delayed task is executed specifically includes:

[0067] According to the delayed task, determining a target slot in the time queue corresponding to the time wheel;

[0068] The unexecuted task is placed into the target slot.

[0069] In this embodiment, the design of the time wheel is based on allocating tasks to different time slots according to time intervals. When executing a delayed task, it is necessary to calculate which "slot" of the time wheel the task should be placed in according to the delay requirement of the task (i.e. the time point of task execution). Each slot represents a specific time period, and the task will be triggered in the corresponding time period. Assuming that the system's time wheel has 100 slots, each slot corresponds to 1 second, then if a task needs to be executed after 30 seconds, the task will be placed in the 30th slot, and when the pointer of the time wheel turns to the 30th slot, the task will be triggered to execute. Once it is determined which time slot the task should be placed in, the task needs to be inserted into the corresponding slot. This means that the delayed execution time of the task has been clarified, and the system places the task in the appropriate position on the time wheel according to the time, and waits for the pointer to reach the position to trigger the task execution. For example, if the delayed task needs to be executed after 15 seconds, the system will put the task into the 15th slot in the time wheel, and the pointer of the time wheel will gradually move forward as time passes. When the pointer reaches the 15th slot, the system will automatically execute the task in the slot.

[0070] It should be noted that the current time wheel design usually has a fixed number of time slots, but in some high-concurrency application scenarios, it may be necessary to dynamically adjust the number of slots according to the amount of tasks. By increasing the number of slots, the scheduling accuracy and task processing efficiency of the system can be improved. The current time wheel scheduling is based on the delay time of the task to execute the task, but it is possible to consider expanding the time wheel scheduling logic to support the priority sorting of tasks. In actual scenarios, some tasks may be more urgent than other tasks and need to be executed first. The payment confirmation task may be more urgent than the data synchronization task. The system can allocate a priority queue for higher priority tasks in the slot of the time wheel to ensure that high priority tasks can be executed as soon as possible. For large-scale systems, when the amount of tasks is huge, a single time wheel may not be able to meet the needs. A distributed time wheel system can be designed, with multiple time wheels working together, and each time wheel is responsible for managing a part of the tasks. This can effectively share the task load and improve the system processing capacity.

[0071] This application ensures that tasks are triggered and executed on time by accurately placing unexecuted tasks into the target slots of the time wheel, optimizes the task scheduling process, and the time wheel mechanism improves the accuracy and efficiency of task management, avoids unnecessary waiting or repeated execution, and enhances the efficiency of the system.

[0072] In some optional implementations of this embodiment, after the above step of placing the unexecuted task into the target slot, the method further includes:

[0073] If the pointer points to the target slot, the unexecuted task is set to a triggered state, and a thread is started to execute the unexecuted task.

[0074] In the present embodiment, the core working mechanism of the time wheel is to mark the current time by a constantly rotating pointer, the pointer points to different time slots, and the slots store tasks that need to be executed at that time point. When the pointer of the time wheel reaches a certain slot, the system will check whether there are tasks in the slot. If there are tasks, the system will set these tasks to "trigger state" and start a special thread to execute these tasks. Assuming that the task needs to be executed after 30 seconds, the task is put into the 30th slot of the time wheel. When the pointer of the time wheel goes to the 30th slot, the system will determine whether there are tasks in the slot. If there are tasks, the system will set these tasks to trigger state, indicating that the task is ready to start execution. Subsequently, the system will start a special thread to execute the task. In addition, an asynchronous execution mechanism can also be designed. When the pointer triggers the task, the system can asynchronously start the execution of the task. Even if the number of tasks is large, the system can also process multiple tasks in parallel through the asynchronous thread pool to improve the efficiency of task execution.

[0075] This application triggers tasks through pointers and starts thread execution, ensuring real-time execution of tasks, reducing the delay caused by traditional scanning methods, and optimizing the use of system resources. Each task is started at the appropriate time, avoiding task backlogs or excessive concurrency, and improving the system's response speed and resource utilization efficiency.

[0076] In some optional implementations of this embodiment, the step of generating a delayed task according to the delayed transaction requirement and adding the delayed task to the target business item specifically includes:

[0077] Receive a task creation instruction carrying configuration information, configure the delayed transaction requirement according to the configuration information, and obtain a JAR file corresponding to the delayed task;

[0078] Integrate the JAR file into the target business project.

[0079] In this embodiment, in the business project, the development engineer or the automation system will send a task creation instruction according to specific needs. The instruction carries configuration information, which may include the delay time, task type, execution frequency, callback mode, etc. of the task. Assuming that a certain business system needs to execute a data synchronization task after 5 minutes, the task creation instruction will include the delayed execution time (5 minutes), task type (data synchronization) and callback interface information. The system dynamically generates a delayed task object according to the configuration information in the task creation instruction, and packages it into a JAR file. The JAR file is a commonly used packaging format for Java applications, which contains classes, resources and configurations required for all tasks. Through the packaging of the JAR file, the delayed task becomes an independently executable module. According to the configuration information specified in the task creation instruction (such as delay time, task type, execution logic, etc.), the system generates a Java class, which is responsible for the specific operation of executing the task, and then packages this class and other related resources into a JAR file so that the business project can be easily integrated and used. The generated JAR file contains all the necessary logic and resources for the delayed task. Next, the JAR file needs to be integrated into the target business project, so that the business project can send delayed task requests to the delayed task platform by calling the functions in the JAR file. For example, the development engineer adds the generated JAR file to the build path of the business project, or imports the JAR file as a dependency into the project through a dependency management tool (such as Maven). The business system registers the delayed task with the delayed task platform by calling the interface in the JAR file.

[0080] This application standardizes the creation, configuration, and integration process of delayed tasks, allowing developers to easily integrate delayed tasks into existing business projects, thereby improving development efficiency. Through flexible configuration file adjustments, it can meet various business needs and reduce errors that may occur during manual configuration and deployment.

[0081] In some optional implementations of this embodiment, the delayed transaction requirement includes extension time information, and after the step of generating a delayed task according to the delayed transaction requirement and adding the delayed task to the target business item, the step further includes:

[0082] Compare the extended time information with the preset input time corresponding to the time wheel to determine whether the extended time of the delayed task is greater than the preset input time;

[0083] If the extended time is less than or equal to the preset insertion time, the process of placing the unexecuted task into the time wheel is not performed.

[0084] In this embodiment, each delayed transaction task will carry an extension time information, indicating the specific time that the task should be delayed. For example, if a task needs to be delayed for 3 minutes, the extension time information is 3 minutes. This extension time information determines the delay time of the task execution. After the task is added to the target business project, the system will compare the extension time information of the task with the preset time wheel entry time. The time wheel entry time is a fixed time interval or time threshold set by the system when designing the time wheel, which is used to control when the task can be added to the time wheel. Assuming that the preset entry time of the time wheel is 1 minute (that is, the system will check the task once every 1 minute), if the extension time of the task is 2 minutes, the system will compare this task with the 1-minute entry time of the time wheel to see if it meets the conditions for joining the time wheel. By comparing the extension time information with the preset time wheel entry time, the system determines whether the extension time of the task exceeds the preset time of the time wheel. If the extension time is short, it may not be necessary to scan the time wheel, and the time wheel can be directly executed or skipped. If the extension time is 2 minutes, and the preset entry time of the time wheel is 1 minute, the extension time is greater than the preset entry time, and the system can choose to add the task to the time wheel; conversely, if the extension time is 0.5 minutes, it is less than the preset entry time, and the system can skip the time wheel operation. If the extension time of the task is less than or equal to the preset entry time of the time wheel, the system does not need to add the task to the time wheel, which means that the system can directly skip the time wheel scanning process, avoid unnecessary processing, and speed up the execution efficiency of the task. If the extension time of a task is 0.5 minutes, and the preset entry time of the time wheel is 1 minute, the system will determine that the extension time is less than the entry time of the time wheel, so the task does not need to be added to the time wheel, and may be executed directly, or processed by other mechanisms.

[0085] It should be noted that the system can dynamically adjust the preset entry time of the time wheel according to business needs. For example, in high concurrency situations, the preset entry time can be set to a shorter time interval to ensure that tasks are processed more promptly; for scenarios with low priority or a small number of tasks, a longer time interval can be set. For tasks of different priorities, the system can design multi-level time wheels. For tasks with longer extended time, the system can assign them to different time wheels or multiple time wheels to ensure that high-priority tasks can be processed first, while low-priority tasks can be postponed.

[0086] This application avoids unnecessary task scheduling and improves resource utilization efficiency by comparing the extended time information with the preset time.

[0087] In some optional implementations of this embodiment, after the step of executing the unexecuted task when the pointer of the time wheel triggers the unexecuted task, the method further includes:

[0088] Obtaining the execution result corresponding to the unexecuted task;

[0089] Analyze the execution result to determine whether there is an abnormal task;

[0090] If the abnormal task exists, return to execute the abnormal task.

[0091] In this embodiment, after the pointer of the time wheel triggers the unexecuted task and executes it successfully, the system needs to obtain the execution result of the task. This result is usually the status of the task execution, such as success, failure, exception, etc. The task execution result is the basis for the subsequent judgment of whether the task is abnormal. After obtaining the execution result of the task, the system needs to analyze the result. The purpose of the analysis is to determine whether the task has an exception, such as the task is not successfully executed as expected, or an error occurs during the execution process. By analyzing the execution result, the system can determine whether the task needs further processing. When the system detects that the task execution result is abnormal, it will return the abnormal task for retry or other exception handling operations. This return execution mechanism can ensure that even if there is a problem with the task during the first execution, the system can try to execute the task again to ensure that the task can be completed in the end.

[0092] This application can effectively improve the success rate of task execution by analyzing the execution results and automatically detecting abnormal tasks. For abnormal tasks, the system will automatically or manually retry to ensure the smooth completion of the task, thereby improving the system's fault tolerance and stability and reducing the need for manual intervention.

[0093] In some optional implementations of this embodiment, after the step of placing the unexecuted tasks of the target business project into a preset time wheel when the delayed task is executed, the method further includes:

[0094] Display the fuse button corresponding to the delayed task on the preset interface;

[0095] When the fuse button is triggered, the thread is started to execute the unexecuted task.

[0096] In this embodiment, a fuse button is provided in the interface of the system to control the execution of the delayed task. The fuse button is usually displayed in the task details page or task list so that the user can view it in real time and trigger the fuse operation when needed. For example, in a business project, if the execution of a delayed task will cause pressure on the downstream business, the administrator can see the task on the interface and manually trigger the execution of the task by clicking the fuse button to prevent the task from continuing to wait for the triggering of the time wheel. When the user clicks the fuse button on the interface, the system will start a new thread to execute the task that has not been executed, and no longer rely on the scheduling of the time wheel. The triggering mechanism of the fuse button enables the user to actively control the execution of the task in an emergency and reduce the delay of task waiting. Suppose there is an order processing task that is delayed, but due to the sharp increase in the business pressure of the system, the administrator decides to manually speed up the execution of this task. By clicking the fuse button in the interface, the system immediately starts a new thread to process the order without waiting for the next triggering of the time wheel.

[0097] This application provides users with the ability to control task execution in real time by providing a fuse button. Especially when business pressure is high, users can manually intervene in task execution to ensure that the task can be completed on time. The fuse button improves the flexibility and controllability of the system, provides an emergency response mechanism, and enhances the efficiency and reliability of the system.

[0098] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0099] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0100] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0101] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0102] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a transaction task delay device based on a time wheel, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0103] like Figure 3 As shown, the transaction task delay device 300 based on the time wheel of this embodiment includes: an acquisition module 301, a generation module 302, an insertion module 303 and an execution module 304. Among them:

[0104] An acquisition module 301 is used to acquire a delayed transaction requirement corresponding to a target business item;

[0105] A generating module 302, configured to generate a delayed task according to the delayed transaction requirement and add the delayed task to the target business item;

[0106] The placing module 303 is used to place the unexecuted tasks of the target business project into a preset time wheel when the delayed task is executed;

[0107] The execution module 304 is configured to execute the unexecuted task when the pointer of the time wheel triggers the unexecuted task.

[0108] The transaction task delay device based on the time wheel provided in the present application improves the task execution efficiency by adding the delayed task to the time wheel, avoids the traditional database scanning method, thereby reducing resource consumption. Tasks are automatically scheduled according to the preset time without human intervention, which simplifies the task management process, ensures the accurate execution of tasks, avoids delays or omissions, and improves the performance and reliability of the system.

[0109] In some optional implementations of this embodiment, the embedding module 303 is further used for:

[0110] According to the delayed task, determining a target slot in the time queue corresponding to the time wheel;

[0111] The unexecuted task is placed into the target slot.

[0112] The transaction task delay device based on the time wheel provided in the present application ensures that the tasks are triggered and executed on time by accurately placing the unexecuted tasks into the target slot of the time wheel, thereby optimizing the task scheduling process. The time wheel mechanism improves the accuracy and efficiency of task management, avoids unnecessary waiting or repeated execution, and enhances the efficiency of the system.

[0113] In some optional implementations of this embodiment, the embedding module 303 is further used for:

[0114] If the pointer points to the target slot, the unexecuted task is set to a triggered state, and a thread is started to execute the unexecuted task.

[0115] The transaction task delay device based on the time wheel provided in the present application triggers the task and starts the thread execution through the pointer, thereby ensuring the real-time execution of the task, reducing the delay caused by the traditional scanning method, and optimizing the use of system resources. Each task is started at the appropriate time, avoiding task backlog or excessive concurrency, and improving the system's response speed and resource utilization efficiency.

[0116] In some optional implementations of this embodiment, the generating module 302 is further configured to:

[0117] Receive a task creation instruction carrying configuration information, configure the delayed transaction requirement according to the configuration information, and obtain a JAR file corresponding to the delayed task;

[0118] Integrate the JAR file into the target business project.

[0119] The time wheel-based transaction task delay device provided in this application standardizes the creation, configuration and integration process of delayed tasks, allowing developers to easily integrate delayed tasks into existing business projects, thereby improving development efficiency; through flexible configuration file adjustment, it can meet various business needs and reduce errors that may occur during manual configuration and deployment.

[0120] In some optional implementations of this embodiment, the above-mentioned delayed transaction requirement includes extended time information, and the generating module 302 is further used to:

[0121] Compare the extended time information with the preset input time corresponding to the time wheel to determine whether the extended time of the delayed task is greater than the preset input time;

[0122] If the extended time is less than or equal to the preset insertion time, the process of placing the unexecuted task into the time wheel is not performed.

[0123] The transaction task delay device based on the time wheel provided in the present application avoids unnecessary task scheduling and improves the efficiency of resource utilization by comparing the extended time information with the preset time.

[0124] In some optional implementations of this embodiment, the execution module 304 is further configured to:

[0125] Obtaining the execution result corresponding to the unexecuted task;

[0126] Analyze the execution result to determine whether there is an abnormal task;

[0127] If the abnormal task exists, return to execute the abnormal task.

[0128] The transaction task delay device based on the time wheel provided in the present application can effectively improve the success rate of task execution by analyzing the execution results and automatically detecting abnormal tasks. For abnormal tasks, the system will automatically or manually retry to ensure the smooth completion of the task, thereby improving the fault tolerance and stability of the system and reducing the need for manual intervention.

[0129] In some optional implementations of this embodiment, the execution module 304 is further configured to:

[0130] Display the fuse button corresponding to the delayed task on the preset interface;

[0131] When the fuse button is triggered, the thread is started to execute the unexecuted task.

[0132] The transaction task delay device based on the time wheel provided in the present application provides users with the ability to control task execution in real time by providing a fuse button. Especially when business pressure is high, users can manually intervene in the execution of tasks to ensure that the tasks can be completed on time. The fuse button improves the flexibility and controllability of the system, provides an emergency response mechanism, and enhances the efficiency and reliability of the system.

[0133] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0134] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0135] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0136] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. equipped on the computer device 4. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of a transaction task delay method based on a time wheel, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0137] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the time-wheel-based transaction task delay method.

[0138] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0139] The computer device provided by the present application improves the efficiency of task execution by adding delayed tasks to the time wheel, avoids the traditional database scanning method, and thus reduces resource consumption. Tasks are automatically scheduled according to preset times without human intervention, which simplifies the task management process and ensures the accurate execution of tasks, avoids delays or omissions, and improves the performance and reliability of the system.

[0140] The present application also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the transaction task delay method based on the time wheel as described above.

[0141] The computer-readable storage medium provided by the present application improves the efficiency of task execution by adding delayed tasks to the time wheel, avoids the traditional database scanning method, thereby reducing resource consumption. Tasks are automatically scheduled according to preset times without human intervention, which simplifies the task management process and ensures the accurate execution of tasks, avoids delays or omissions, and improves the performance and reliability of the system.

[0142] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0143] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A transaction task delay method based on a time wheel, characterized in that: The steps include: Obtain the delayed transaction requirements corresponding to the target business project; According to the delayed transaction requirement, generating a delayed task and adding the delayed task to the target business item; When the delayed task is executed, the unexecuted tasks of the target business project are placed into a preset time wheel; When the pointer of the time wheel triggers the unexecuted task, the unexecuted task is executed.

2. The transaction task delay method based on the time wheel according to claim 1 is characterized in that: The step of placing the unexecuted tasks of the target business project into a preset time wheel when the delayed tasks are executed specifically includes: According to the delayed task, determining a target slot in the time queue corresponding to the time wheel; The unexecuted task is placed into the target slot.

3. The transaction task delay method based on the time wheel according to claim 2 is characterized in that: After the step of placing the unexecuted task into the target slot, the method further includes: If the pointer points to the target slot, the unexecuted task is set to a triggered state, and a thread is started to execute the unexecuted task.

4. The transaction task delay method based on the time wheel according to claim 1 is characterized in that: The step of generating a delayed task according to the delayed transaction requirement and adding the delayed task to the target business item specifically includes: Receive a task creation instruction carrying configuration information, configure the delayed transaction requirement according to the configuration information, and obtain a JAR file corresponding to the delayed task; Integrate the JAR file into the target business project.

5. The transaction task delay method based on the time wheel according to claim 1 is characterized in that: The delayed transaction requirement includes extended time information. After the step of generating a delayed task according to the delayed transaction requirement and adding the delayed task to the target business item, the method further includes: Compare the extended time information with the preset input time corresponding to the time wheel to determine whether the extended time of the delayed task is greater than the preset input time; If the extended time is less than or equal to the preset insertion time, the process of placing the unexecuted task into the time wheel is not performed.

6. The transaction task delay method based on the time wheel according to claim 1 is characterized in that: After the step of executing the unexecuted task when the pointer of the time wheel triggers the unexecuted task, the method further includes: Obtaining the execution result corresponding to the unexecuted task; Analyze the execution result to determine whether there is an abnormal task; If the abnormal task exists, return to execute the abnormal task.

7. The transaction task delay method based on the time wheel according to any one of claims 1 to 6, characterized in that: After the step of placing the unexecuted tasks of the target business project into a preset time wheel when the delayed task is executed, the method further includes: Display the fuse button corresponding to the delayed task on the preset interface; When the fuse button is triggered, the thread is started to execute the unexecuted task.

8. A transaction task delay device based on a time wheel, characterized in that: include: An acquisition module is used to obtain the delayed transaction requirements corresponding to the target business project; A generating module, used for generating a delayed task according to the delayed transaction requirement and adding the delayed task to the target business item; An inserting module, used for inserting the unexecuted tasks of the target business project into a preset time wheel when the delayed task is executed; An execution module is used to execute the unexecuted task when the pointer of the time wheel triggers the unexecuted task.

9. A computer device, characterized in that: It comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the transaction task delay method based on the time wheel as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the transaction task delay method based on the time wheel as described in any one of claims 1 to 7 are implemented.