Financial platform task processing method and device, storage medium and electronic equipment
Through multi-level time wheel components and database storage mechanisms, it solves the problems of low efficiency of scheduled task management and difficulty in restart and recovery in financial platforms, achieves efficient task processing and automatic recovery, and improves the stability and reliability of the platform.
Patent Information
- Application Number
- CN202411087073.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-10-18
AI Technical Summary
The number of scheduled tasks in financial platforms has increased, and traditional timer management methods are difficult to meet performance and efficiency requirements. In practical applications, the simple time wheel algorithm has problems with persistence of timer status and difficulty in restart recovery, resulting in unsatisfactory task processing efficiency.
A multi-level time wheel component is used for task expiration polling, combined with a database to store task information, to implement task status update and retry mechanisms to ensure that scheduled tasks are automatically restored after the financial platform is restarted.
It achieves efficient management and triggering of a large number of scheduled tasks to ensure task processing efficiency, and automatically resumes scheduled tasks after the financial platform restarts, improving the stability and reliability of the platform.
Smart Images

Figure CN118798481A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to a financial platform task processing method, device, storage medium and electronic device. Background Art
[0002] In the business processing of financial platforms, scheduled tasks and delayed tasks are indispensable parts, such as order timeout cancellation, regular data backup, scheduled message push, etc. The implementation of tasks depends on timers. However, as the scale of financial platforms expands, the number of scheduled tasks increases dramatically, and traditional timer management methods (such as simple linear scanning) are gradually unable to meet the needs in terms of performance and efficiency.
[0003] In the related technology, the time wheel algorithm has become a widely adopted solution due to its efficient time complexity and good scalability. However, in practical applications, the simple time wheel algorithm still has the problem of persistence of timer status, and the problem of difficulty in restoring the timer when the financial platform is restarted, resulting in unsatisfactory task processing efficiency.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a financial platform task processing method, device, storage medium and electronic device to at least solve the technical problem of unsatisfactory task processing efficiency existing in the related art.
[0006] According to one aspect of an embodiment of the present invention, a financial platform task processing method is provided, comprising: in response to a restart process of a financial platform, determining a plurality of tasks in a database whose corresponding task information indicates an unfinished state, wherein the database is used to record task information corresponding to tasks from the financial platform; generating a time wheel component based on the task information respectively corresponding to the plurality of tasks, wherein the time wheel component includes time wheels of multiple levels, and the time wheels of the multiple levels respectively perform expiration polling on added tasks according to different time granularities; adding the plurality of tasks to the time wheel component for expiration polling, and obtaining polling results respectively corresponding to the plurality of tasks; when the polling result of a target task among the plurality of tasks is expiration, performing task processing on the target task, and obtaining a task processing result of the target task; based on the task processing result of the target task, performing a status update on the task information corresponding to the target task stored in the database.
[0007] Optionally, the task information includes a task type and an execution time, and generating a timing wheel component based on the task information respectively corresponding to the multiple tasks includes: determining, according to the task types respectively corresponding to the multiple tasks, time granularities respectively corresponding to the multiple tasks from a plurality of predetermined candidate granularities; determining the levels of the multiple levels of timing wheels based on the time granularities respectively corresponding to the multiple tasks; and generating the timing wheel component based on the levels.
[0008] Optionally, the task information includes execution time, and generating a timing wheel component based on the task information corresponding to the multiple tasks includes: determining the number of time slots respectively included in the multiple levels of timing wheels based on the execution times respectively corresponding to the multiple tasks; using the number of slots to divide the multiple levels of timing wheels into time slots respectively, to generate the timing wheel component.
[0009] Optionally, the multiple levels of time wheels respectively include time slots with corresponding numbers of slots, and the method further includes: for any task among the multiple tasks, based on the task type of the arbitrary task, determining the time wheel of the target level corresponding to the arbitrary task, wherein the time wheel of the target level belongs to the time wheels of the multiple levels; based on the execution time of the arbitrary task, adding the arbitrary task to the target slot of the target level, wherein the target slot belongs to the time slots with corresponding numbers of slots included in the target layer; and adding the multiple tasks to the time wheel component respectively by adding the arbitrary task to the time wheel component.
[0010] Optionally, the method also includes: determining the number of tasks corresponding to the time wheels of the multiple levels respectively; determining a time wheel of the first level whose number of tasks among the multiple levels is less than a predetermined first number threshold, and a time wheel of the second level whose time granularity is smaller than the time granularity of the first level and is adjacent to the time wheel of the first level, wherein the time wheel of the first level is a time wheel of any level except the time wheel with the smallest corresponding time granularity among the multiple levels; migrating the tasks included in the time wheel of the first level to the time wheel of the second level, and removing the time wheel of the first level.
[0011] Optionally, based on the task processing result of the target task, the status of the task information corresponding to the target task stored in the database is updated, including: when the task processing result indicates that the task execution has failed, updating the task information corresponding to the target task to a retry status; adding the target task to the time wheel component for polling processing according to a predetermined retry interval; until the target task reaches a predetermined number of retries and the task processing result is a task execution failure, sending an exception prompt message indicating that the target task is abnormal to the exception handling end.
[0012] Optionally, the method also includes: in response to the restart processing of the financial platform, detecting whether a first time base corresponding to the financial platform and a second time base corresponding to the time wheel component are the same; when the first time base is different from the second time base, updating the second time base based on the first time base to obtain an updated second time base.
[0013] According to another aspect of an embodiment of the present invention, a financial platform task processing device is provided, comprising: a task recording module, for determining, in response to a restart process of a financial platform, a plurality of tasks whose corresponding task information in a database indicates an unfinished state, wherein the database is used to record task information corresponding to tasks from the financial platform; a first polling module, for generating a time wheel component based on task information respectively corresponding to the plurality of tasks, wherein the time wheel component comprises time wheels of a plurality of levels, and the time wheels of the plurality of levels respectively perform expiration polling on added tasks according to different time granularities; a second polling module, for adding the plurality of tasks to the time wheel component for expiration polling, and obtaining polling results respectively corresponding to the plurality of tasks; a task processing module, for executing task processing on a target task among the plurality of tasks, when the polling result of the target task is expiration, and obtaining a task processing result of the target task; and a status updating module, for performing status update on the task information corresponding to the target task stored in the database based on the task processing result of the target task.
[0014] According to another aspect of an embodiment of the present invention, a non-volatile storage medium is provided, wherein the non-volatile storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing any one of the financial platform task processing methods.
[0015] According to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising: one or more processors and a memory, wherein the memory is used to store 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 any one of the financial platform task processing methods.
[0016] In an embodiment of the present invention, a financial platform task processing method is adopted, and by responding to the restart processing of the financial platform, multiple tasks whose corresponding task information in the database indicates an unfinished state are determined, wherein the database is used to record the task information corresponding to the tasks from the financial platform; based on the task information corresponding to the multiple tasks, a time wheel component is generated, wherein the time wheel component includes multiple levels of time wheels, and the multiple levels of time wheels perform expiration polling on the added tasks according to different time granularities; the multiple tasks are added to the time wheel component for expiration polling, and the polling results corresponding to the multiple tasks are obtained; when the polling result of the target task among the multiple tasks is expiration, the task processing of the target task is performed to obtain the task processing result of the target task; based on the task processing result of the target task, the task information corresponding to the target task stored in the database is updated. The purpose of efficiently managing and triggering a large number of scheduled tasks is achieved, and the scheduled tasks can be automatically restored after the restart of the financial platform, and the technical effect of improving the task processing efficiency is achieved, thereby solving the technical problem of unsatisfactory task processing efficiency existing in the related technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0018] Figure 1 is a flowchart of an optional financial platform task processing method provided according to an embodiment of the present invention;
[0019] Figure 2 is a schematic diagram of an optional financial platform task processing method provided according to an embodiment of the present invention;
[0020] Figure 3 It is a schematic diagram of an optional financial platform task processing device provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] For the convenience of description, some nouns or terms involved in the embodiments of the present application are explained below:
[0024] Timing wheel algorithm: An algorithm for efficiently managing a large number of timers by assigning the timers to different time slots so that the timers can be checked and triggered quickly.
[0025] Timer polling: The process of periodically checking whether a timer has expired and triggering corresponding actions.
[0026] Database persistence: Save data to the database so that it can be reloaded after the financial platform is restarted or recovered from a failure, ensuring data persistence and reliability.
[0027] According to an embodiment of the present invention, an optional method embodiment of financial platform task processing is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0028] Figure 1 is a flowchart of an optional financial platform task processing method provided according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0029] Step S102, in response to the restart process of the financial platform, determining a plurality of tasks whose corresponding task information in a database indicates that they are in an unfinished state, wherein the database is used to record task information corresponding to tasks from the financial platform;
[0030] It can be understood that the database is used to record detailed task information corresponding to the tasks of the financial platform. In the restart process of the financial platform, it is determined that the task information corresponding to the tasks in the database indicates that multiple tasks are in an unfinished state. Querying the task information through the database layer ensures the data consistency between the financial platform and the database, which helps to reduce problems and errors caused by inconsistent data.
[0031] Optionally, the above database storage structure can be designed in a variety of ways, for example, a scheduled task table is designed to store information such as task ID (Identification), execution time, and task status. When the financial platform adds, modifies, or deletes scheduled tasks, the database is updated in real time. When the financial platform is started, the task data is loaded from the database to restore the scheduled tasks. A reasonable data storage structure is designed to ensure that scheduled tasks and their status can be quickly accessed, and a data recovery mechanism is provided to quickly restore scheduled tasks after the financial platform is restarted.
[0032] In an optional embodiment, the method also includes: in response to the restart processing of the financial platform, detecting whether the first time base corresponding to the financial platform and the second time base corresponding to the time wheel component are the same; when the first time base is different from the second time base, updating the second time base based on the first time base to obtain an updated second time base.
[0033] It can be understood that in response to the restart process of the financial platform, the first time reference corresponding to the financial platform and the second time reference corresponding to the time wheel component are recorded, and whether the first time reference and the second time reference are the same is detected. If the first time reference and the second time reference are not the same, the second time reference is changed based on the first time reference to obtain the changed second time reference. By ensuring the time consistency of the financial platform time and the time wheel component, errors and anomalies caused by time differences are avoided, and the stability and reliability of the entire financial platform are enhanced.
[0034] Step S104, generating a time wheel component based on the task information corresponding to the multiple tasks, wherein the time wheel component includes multiple levels of time wheels, and the multiple levels of time wheels perform expiration polling on the added tasks according to different time granularities;
[0035] It can be understood that based on the task information corresponding to multiple tasks, a time wheel component including multiple levels of time wheels is generated, each level represents a different time accuracy or time range, and the time wheels of multiple levels perform expiration polls for the added tasks according to different time granularities, thereby meeting the time accuracy requirements of different types of tasks.
[0036] Optionally, the time accuracy or time range of the above tasks may be various, for example, minute-level tasks, hour-level tasks, or day-level tasks.
[0037] In an optional embodiment, the task information includes the task type and the execution time, and a timing wheel component is generated based on the task information corresponding to the multiple tasks, including: determining the time granularities corresponding to the multiple tasks from a plurality of predetermined candidate granularities according to the task types corresponding to the multiple tasks; determining the levels of multiple levels of timing wheels based on the time granularities corresponding to the multiple tasks; and generating the timing wheel component based on the levels.
[0038] It can be understood that the task information includes the task type and execution time. Based on the task information corresponding to the multiple tasks and the predetermined multiple candidate granularities, the time granularities corresponding to the multiple tasks are determined, the levels of the multiple levels of time wheels are obtained, and the time wheel components are generated. Tasks are assigned to time wheels of different levels, and resources are reasonably allocated according to the execution frequency and time requirements of the tasks, avoiding waste and conflict of resources.
[0039] Optionally, the above-mentioned multiple levels of time wheels can be multiple, for example, two different levels of first-level time wheels and second-level time wheels are exemplified, the first-level time wheel is responsible for managing short-term scheduled tasks, and the second-level time wheel is responsible for managing long-term scheduled tasks. The first-level time wheel is a basic time wheel structure, which is composed of a series of fixed-size slots (i.e., time slots), and each slot represents a time unit (such as 1 second). The second-level time wheel is an extension of the first-level time wheel, which can be composed of multiple first-level time wheels, and the slot of each second-level time wheel represents a longer time unit (such as 1 minute or 1 hour). Each time slot corresponds to a linked list to store corresponding scheduled tasks. The time wheel structure of multiple levels is adopted to reduce the number of time wheel slots and improve the accuracy and efficiency of scheduled task management.
[0040] In an optional embodiment, the task information includes the execution time, and a timing wheel component is generated based on the task information corresponding to the multiple tasks, including: determining the number of time slots respectively included in the timing wheels of multiple levels based on the execution times respectively corresponding to the multiple tasks; using the number of slots to divide the timing wheels of multiple levels into time slots respectively, and generating a timing wheel component.
[0041] It can be understood that based on the execution times corresponding to the multiple tasks, the number of time slots respectively included in the time wheels of the multiple levels is determined, and the number of slots is used to divide the time wheels of the multiple levels into time slots to generate time wheel components. Each slot can be a linked list or an array for storing tasks to be executed. By setting different time slot numbers for time wheels of different levels and accurately dividing the number of slots, the efficiency of task scheduling is improved.
[0042] In an optional embodiment, the method also includes: determining the number of tasks corresponding to time wheels of multiple levels respectively; determining a time wheel of a first level whose number of tasks among the multiple levels is less than a predetermined first number threshold, and a time wheel of a second level whose time granularity is smaller than the time granularity of the first level and is adjacent to the time wheel of the first level, wherein the time wheel of the first level is a time wheel of any level except the time wheel with the smallest corresponding time granularity among the multiple levels; migrating the tasks included in the time wheel of the first level to the time wheel of the second level, and removing the time wheel of the first level.
[0043] It can be understood that the number of tasks corresponding to the time wheels of multiple levels is determined, and the number of tasks in the multiple levels should be less than the time wheel of the first level with a predetermined first quantity threshold, and the first quantity threshold is used to determine whether the time wheel is saturated. The time granularity is smaller than the time granularity of the first level, and the time wheel adjacent to the time wheel of the first level is the time wheel of the second level. For example, if the first level is an hourly time wheel, the adjacent second level time wheel is a minute-level time wheel. The time wheel of the first level is a time wheel of any level except the time wheel with the smallest corresponding time granularity among the multiple levels. If the tasks included in the time wheel of the first level are migrated to the time wheel of the second level, the time wheel of the first level is removed after the migration is completed, thereby reducing unnecessary levels and improving scheduling efficiency.
[0044] Step S106, adding multiple tasks to the time wheel component to perform expiration polling, and obtaining polling results corresponding to the multiple tasks respectively;
[0045] It can be understood that multiple tasks are added to the time wheel component for expiration polling, the status of the task information is checked, and the polling results corresponding to the multiple tasks are obtained. Expiration polling through the time wheel component reduces unnecessary task traversal and improves the execution efficiency of scheduled tasks.
[0046] The above polling method can be multiple, for example, polling is performed at a fixed time interval, and the time slot of the first-level time wheel is checked first. If there is a task due, it is triggered immediately; if there is no task due, the time slot of the second-level time wheel is checked. If there is a task due in the second-level time slot, it is triggered immediately, and the due task of the corresponding second-level time slot is taken out, and the task is placed in the time slot of the first-level time wheel. If there is no task due, wait for the next round of polling. Design an efficient polling mechanism to ensure that it can be triggered in time when the scheduled task expires, and avoid the burden of the system financial platform caused by frequent polling. In an optional embodiment, the time wheels of multiple levels include time slots of corresponding slot numbers, and the method also includes: for any task among the multiple tasks, based on the task type of any task, determine the time wheel of the target level corresponding to any task, wherein the time wheel of the target level belongs to the time wheels of multiple levels; based on the execution time of any task, add any task to the target slot of the target level, wherein the target slot belongs to the time slot of the corresponding slot number included in the target layer; adopt the method of adding any task to the time wheel component, and add multiple tasks to the time wheel component respectively.
[0047] It can be understood that the time wheels of multiple levels respectively include time slots of corresponding slot numbers. For the task type of any task among multiple tasks, the time wheel of the target level corresponding to any task is determined, and the any task is added to the target time slot according to the execution time of any task. In this way, multiple tasks are added to the time wheel component. The multi-level time wheels are allocated to the appropriate level according to the task type and execution time, optimizing the scheduling efficiency and realizing efficient task scheduling.
[0048] Step S108, when the polling result of the target task among the multiple tasks is expired, executing task processing on the target task to obtain the task processing result of the target task;
[0049] It can be understood that when the polling result of the target task among multiple tasks is due, the target task is processed to obtain the task processing result. By polling the task status, the financial platform can immediately respond to the due task to ensure that the task is processed in time.
[0050] In an optional embodiment, based on the task processing result of the target task, the status of the task information corresponding to the target task stored in the database is updated, including: when the task processing result indicates that the task execution failed, the task information corresponding to the target task is updated to a retry status; the target task is added to the time wheel component for polling processing according to a predetermined retry interval; until the target task reaches a predetermined number of retries and the task processing result is a task execution failure, an exception prompt message indicating that the target task is abnormal is sent to the exception handling end.
[0051] It can be understood that based on the task processing result of the target task, the task information of the task target in the database is updated. If the task processing result indicates that the task has failed, the task information corresponding to the target task is updated to the retry state, and the target task is added to the time wheel component for polling at a predetermined time interval. When the target task reaches the predetermined number of retries, the abnormal prompt information of the target task abnormality is sent to the abnormal processing end. By automatically identifying task failures and entering the retry state, the financial platform can self-recover when encountering abnormalities or failures, thereby enhancing the reliability of the platform.
[0052] Step S110: based on the task processing result of the target task, the task information corresponding to the target task stored in the database is updated.
[0053] It can be understood that the status of the task information corresponding to the target task stored in the database is updated in real time according to the task processing result of the target task. By updating the task status in real time, the consistency of the information in the database with the current task execution status is ensured, and information delay and error are reduced.
[0054] Through the above step S102, in response to the restart processing of the financial platform, multiple tasks whose corresponding task information in the database indicates that they are in an unfinished state are determined, wherein the database is used to record the task information corresponding to the tasks from the financial platform; step S104, based on the task information corresponding to the multiple tasks, a time wheel component is generated, wherein the time wheel component includes multiple levels of time wheels, and the multiple levels of time wheels perform expiration polling on the added tasks according to different time granularities; step S106, multiple tasks are added to the time wheel component for expiration polling, and the polling results corresponding to the multiple tasks are obtained; step S108, when the polling result of the target task among the multiple tasks is expiration, the task processing of the target task is performed to obtain the task processing result of the target task; step S110, based on the task processing result of the target task, the task information corresponding to the target task stored in the database is updated. It can achieve the purpose of efficiently managing and triggering a large number of scheduled tasks, and automatically recovering the scheduled tasks after the restart of the financial platform, and achieve the technical effect of improving the task processing efficiency, thereby solving the technical problem of unsatisfactory task processing efficiency existing in the related technology.
[0055] Based on the above embodiments and optional embodiments, the present invention proposes an optional implementation mode: Figure 2 is a schematic diagram of an optional financial platform task processing method provided according to an embodiment of the present invention, such as Figure 2 shown.
[0056] Step S1, when the financial platform starts, the initialization code is executed, including configuring resources, setting environment variables, and loading necessary services and components.
[0057] Step S2, load task data from the database, load predefined tasks from the database, and query and return task information of all tasks to be executed, including task name, execution time, cycle, etc., by executing SQL query.
[0058] Step S3, initializing the time wheel, initializing the time wheel according to the execution time and cycle of the task, the initialization of the time wheel involves creating time slots, assigning tasks to corresponding time slots, and setting polling intervals.
[0059] Based on the task information corresponding to multiple tasks, a time wheel component containing multiple levels of time wheels is generated. Each level represents a different time accuracy or time range. The time wheels of multiple levels perform expiration polling on the added tasks according to different time granularities, meeting the time accuracy requirements of different types of tasks.
[0060] The task information includes the task type and execution time. Based on the task information corresponding to multiple tasks and the predetermined multiple candidate granularities, the time granularities corresponding to the multiple tasks are determined, the levels of multiple levels of time wheels are obtained, and the time wheel components are generated. Tasks are assigned to time wheels at different levels, and resources are reasonably allocated according to the execution frequency and time requirements of tasks, avoiding waste and conflict of resources.
[0061] The above-mentioned multiple levels of time wheels can be of multiple types. For example, the time wheel is divided into a primary time wheel and a secondary time wheel. The primary time wheel is responsible for managing short-term scheduled tasks, and the secondary time wheel is responsible for managing long-term scheduled tasks. The primary time wheel is a basic time wheel structure, which consists of a series of fixed-size slots, each slot representing a time unit (such as 1 second). The secondary time wheel is an extension of the primary time wheel. It consists of multiple primary time wheels, and the slot of each secondary time wheel represents a longer time unit (such as 1 minute or 1 hour). Each time slot corresponds to a linked list to store the corresponding scheduled tasks. A multi-level time wheel structure is adopted to reduce the number of time wheel slots and improve the accuracy and efficiency of scheduled task management.
[0062] Based on the execution times corresponding to multiple tasks, the number of time slots included in the time wheels of multiple levels is determined, and the time slots of the time wheels of multiple levels are divided by the number of slots to generate time wheel components. Each slot can be a linked list or an array for storing tasks to be executed. By setting different time slot numbers for time wheels of different levels and accurately dividing the slot numbers, the efficiency of task scheduling is improved.
[0063] Step S4, start timer polling, the timer polling checks the first-level time wheel to determine whether the task is due, if so, trigger the task and update the task status to the database; if not, check whether there is a task due in the second-level time wheel, if so, trigger the task and update the task status to the database; if not, wait for the next polling.
[0064] Add multiple tasks to the time wheel component for expiration polling, check the status of task information, and obtain the polling results corresponding to multiple tasks. Performing expiration polling through the time wheel component reduces unnecessary task traversal and improves the execution efficiency of scheduled tasks.
[0065] There are many ways to poll. For example, polling can be performed at fixed time intervals, with priority given to checking the time slots of the first-level time wheel. If a task is due, it will be triggered immediately. If no task is due, the time slots of the second-level time wheel will be checked. If a task is due in the second-level time slot, it will be triggered immediately, and the due task of the corresponding second-level time slot will be taken out and put into the time slot of the first-level time wheel. If no task is due, wait for the next round of polling. Design an efficient polling mechanism to ensure that it can be triggered in time when the scheduled task expires, while avoiding the burden on the financial platform caused by frequent polling.
[0066] When the polling result of the target task among multiple tasks is due, the target task is processed to obtain the task processing result. By polling the task status, the financial platform can immediately respond to the due tasks to ensure that the tasks are processed in a timely manner.
[0067] Based on the task processing result of the target task, the task information of the task target in the database is updated. If the task processing result indicates that the task has failed, the task information corresponding to the target task is updated to the retry state. At the predetermined time interval, the target task is added to the time wheel component for polling. When the target task reaches the predetermined number of retries, the abnormal prompt information of the target task abnormality is sent to the abnormal processing end. By automatically identifying task failures and entering the retry state, the financial platform can self-recover when encountering abnormalities or failures, enhancing the reliability of the platform.
[0068] According to the task processing results of the target task, the status of the task information corresponding to the target task stored in the database is updated in real time. By updating the task status in real time, the consistency of the information in the database with the current task execution status is ensured, reducing information delays and errors.
[0069] The above optional implementation method achieves at least the following effects: using the time wheel algorithm to allocate a large number of scheduled tasks to different time slots, efficiently managing a large number of scheduled tasks, reducing time complexity, and improving the performance of the financial platform; using the optimized timer polling mechanism to ensure that scheduled tasks can be triggered in time when they expire to meet business needs; through the database persistence module, the data security of scheduled tasks and the high reliability of the financial platform are guaranteed. Even if the financial platform fails, the scheduled tasks can be quickly and automatically restored after the financial platform is restarted, reducing business interruption time, improving the stability and reliability of the financial platform, and the continuity of task execution. Through data consistency and integrity, data loss or repeated execution of tasks caused by abnormal financial platforms is avoided. The database records and monitors the status and historical execution of scheduled tasks for easy management and analysis. Combined with database persistence, the financial platform is more flexible and scalable when expanding new functions and increasing task management requirements.
[0070] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0071] In this embodiment, a financial platform task processing device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the terms "module" and "device" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0072] According to an embodiment of the present invention, there is also provided an apparatus embodiment for implementing a financial platform task processing method. Figure 3 is a schematic diagram of an optional financial platform task processing device provided according to an embodiment of the present invention, such as Figure 3 As shown, the above-mentioned financial platform task processing device includes a task recording module 302, a first polling module 304, a second polling module 306, a task processing module 308, and a status updating module 310. The device is described below.
[0073] A task recording module 302, configured to determine, in response to the restart process of the financial platform, a plurality of tasks whose corresponding task information in a database indicates an unfinished state, wherein the database is configured to record task information corresponding to tasks from the financial platform;
[0074] The first polling module 304 is connected to the task recording module 302 and is used to generate a time wheel component based on the task information corresponding to the multiple tasks, wherein the time wheel component includes multiple levels of time wheels, and the multiple levels of time wheels perform expiration polling on the added tasks according to different time granularities;
[0075] The second polling module 306 is connected to the first polling module 304 and is used to add multiple tasks to the time wheel component for expiration polling to obtain polling results corresponding to the multiple tasks respectively;
[0076] The task processing module 308 is connected to the second polling module 306 and is used to perform task processing on the target task in the plurality of tasks to obtain the task processing result of the target task when the polling result of the target task is expired;
[0077] The status update module 310 is connected to the task processing module 308 and is used to update the status of the task information corresponding to the target task stored in the database based on the task processing result of the target task.
[0078] In a financial platform task processing device provided by an embodiment of the present invention, a task recording module 302 is set to respond to the restart processing of the financial platform, and multiple tasks whose corresponding task information in the database indicates that they are in an unfinished state are determined, wherein the database is used to record the task information corresponding to the tasks from the financial platform; a first polling module 304 is connected to the task recording module 302, and is used to generate a time wheel component based on the task information corresponding to the multiple tasks, wherein the time wheel component includes multiple levels of time wheels, and the multiple levels of time wheels perform expiration polling on the added tasks according to different time granularities; a second polling module 306 is connected to the first polling module 304, and is used to add the multiple tasks to the time wheel component for expiration polling, and obtain the polling results corresponding to the multiple tasks; a task processing module 308 is connected to the second polling module 306, and is used to perform task processing on the target task in the case that the polling result of the target task among the multiple tasks is expiration, and obtain the task processing result of the target task; a status update module 310 is connected to the task processing module 308, and is used to perform status update on the task information corresponding to the target task stored in the database based on the task processing result of the target task. The purpose of efficiently managing and triggering a large number of scheduled tasks is achieved, and the scheduled tasks can be automatically restored after the financial platform is restarted, achieving the technical effect of improving task processing efficiency, and thus solving the technical problem of unsatisfactory task processing efficiency existing in related technologies.
[0079] It should be noted that the above modules can be implemented by software or hardware. For example, for the latter, it can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0080] It should be noted that the task recording module 302, the first polling module 304, the second polling module 306, the task processing module 308, and the status updating module 310 correspond to steps S102 to S110 in the embodiment, and the examples and application scenarios implemented by the modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above embodiment. It should be noted that the modules as part of the device can be run in a computer terminal.
[0081] It should be noted that the optional or preferred implementation of this embodiment can refer to the relevant description in the embodiment, which will not be repeated here.
[0082] The above-mentioned financial platform task processing device may also include a processor and a memory. The task recording module 302, the first polling module 304, the second polling module 306, the task processing module 308, the status update module 310, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize the corresponding functions.
[0083] The processor includes a kernel, which retrieves the corresponding program unit from the memory. There can be one or more kernels. The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one storage chip.
[0084] An embodiment of the present invention provides a non-volatile storage medium on which a program is stored. When the program is executed by a processor, a financial platform task processing method is implemented.
[0085] An embodiment of the present invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and can be run on the processor. When the processor executes the program, the following steps are implemented: in response to the restart processing of the financial platform, multiple tasks whose corresponding task information in the database indicates an unfinished state are determined, wherein the database is used to record the task information corresponding to the tasks from the financial platform; based on the task information corresponding to the multiple tasks, a time wheel component is generated, wherein the time wheel component includes multiple levels of time wheels, and the multiple levels of time wheels perform expiration polling on the added tasks according to different time granularities; multiple tasks are added to the time wheel component for expiration polling, and the polling results corresponding to the multiple tasks are obtained; when the polling result of the target task among the multiple tasks is expiration, the task processing of the target task is performed to obtain the task processing result of the target task; based on the task processing result of the target task, the task information corresponding to the target task stored in the database is updated. The device in this article can be a server, a PC, etc.
[0086] The present invention also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: in response to a restart process of a financial platform, determining a plurality of tasks in a database whose corresponding task information indicates an unfinished state, wherein the database is used to record the task information corresponding to the tasks from the financial platform; generating a time wheel component based on the task information corresponding to the plurality of tasks, wherein the time wheel component includes time wheels of a plurality of levels, and the time wheels of the plurality of levels perform expiration polling on the added tasks according to different time granularities; adding the plurality of tasks to the time wheel component for expiration polling, and obtaining polling results corresponding to the plurality of tasks; when the polling result of a target task among the plurality of tasks is expiration, performing task processing on the target task, and obtaining the task processing result of the target task; based on the task processing result of the target task, updating the status of the task information corresponding to the target task stored in the database.
[0087] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0088] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0089] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0090] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0091] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0092] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0093] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0094] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0095] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0096] The above are only embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.
Claims
1. A financial platform task processing method, characterized in that: include: In response to the restart process of the financial platform, determining a plurality of tasks whose corresponding task information in a database indicates an unfinished state, wherein the database is used to record the task information corresponding to the tasks from the financial platform; Based on the task information respectively corresponding to the multiple tasks, a time wheel component is generated, wherein the time wheel component includes multiple levels of time wheels, and the multiple levels of time wheels respectively perform expiration polling on the added tasks according to different time granularities; Adding the multiple tasks to the time wheel component to perform expiration polling, and obtaining polling results corresponding to the multiple tasks respectively; When the polling result of a target task among the multiple tasks is expired, executing task processing on the target task to obtain a task processing result of the target task; Based on the task processing result of the target task, the task information corresponding to the target task stored in the database is updated in status.
2. The method according to claim 1, characterized in that The task information includes a task type and an execution time, and the generating of a time wheel component based on the task information corresponding to the plurality of tasks respectively includes: According to the task types respectively corresponding to the multiple tasks, determine the time granularities respectively corresponding to the multiple tasks from a plurality of predetermined candidate granularities; Determining the levels of the multiple levels of time wheels based on the time granularities respectively corresponding to the multiple tasks; Based on the number of stages, the time wheel component is generated.
3. The method according to claim 1, characterized in that: The task information includes the execution time, and the generating of the time wheel component based on the task information respectively corresponding to the multiple tasks includes: Based on the execution times corresponding to the multiple tasks, respectively, determining the number of time slots respectively included in the time wheels of the multiple levels; The time wheels of the multiple levels are divided into time slots using the number of slots to generate the time wheel components.
4. The method according to claim 1, characterized in that: The time wheels of the multiple levels respectively include time slots of corresponding numbers, and the method further includes: For any task among the multiple tasks, determining a time wheel of a target level corresponding to the arbitrary task based on a task type of the arbitrary task, wherein the time wheel of the target level belongs to the time wheels of the multiple levels; Based on the execution time of the arbitrary task, adding the arbitrary task to the target slot of the target level, wherein the target slot belongs to the time slot of the corresponding number of slots included in the target level; The arbitrary task is added to the time wheel component, and the multiple tasks are added to the time wheel component respectively.
5. The method according to claim 1, characterized in that The method further comprises: Determine the number of tasks corresponding to the time wheels of the multiple levels respectively; Determine a time wheel of a first level in which the number of tasks in the multiple levels is less than a predetermined first number threshold, and a time wheel of a second level whose time granularity is smaller than the time granularity of the first level and is adjacent to the time wheel of the first level, wherein the time wheel of the first level is a time wheel of any level except the time wheel with the smallest corresponding time granularity in the multiple levels; The tasks included in the time wheel of the first level are migrated to the time wheel of the second level, and the time wheel of the first level is removed.
6. The method according to claim 1, characterized in that The step of updating the status of task information corresponding to the target task stored in the database based on the task processing result of the target task includes: When the task processing result indicates that the task execution has failed, the task information corresponding to the target task is updated to a retry state; Adding the target task to the time wheel component for polling processing according to a predetermined retry interval; Until the target task reaches a predetermined number of retries and the task processing result is a task execution failure, an abnormal prompt message indicating that the target task is abnormal is sent to the abnormal processing end.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: In response to the restart process of the financial platform, detecting whether a first time reference corresponding to the financial platform and a second time reference corresponding to the time wheel component are the same; When the first time reference is different from the second time reference, the second time reference is updated based on the first time reference to obtain an updated second time reference.
8. A financial platform task processing device, characterized in that: include: A task recording module, configured to, in response to the restart process of the financial platform, determine a plurality of tasks whose corresponding task information in a database indicates an unfinished state, wherein the database is configured to record task information corresponding to tasks from the financial platform; A first polling module is used to generate a time wheel component based on the task information corresponding to the multiple tasks, wherein the time wheel component includes multiple levels of time wheels, and the multiple levels of time wheels perform expiration polling on the added tasks according to different time granularities; A second polling module is used to add the multiple tasks to the time wheel component to perform expiration polling, and obtain polling results corresponding to the multiple tasks respectively; A task processing module, used for executing task processing on a target task among the multiple tasks to obtain a task processing result of the target task when the polling result of the target task is expired; The status update module is used to update the status of the task information corresponding to the target task stored in the database based on the task processing result of the target task.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the financial platform task processing method described in any one of claims 1 to 7.
10. An electronic device, characterized in that: include: One or more processors and a memory, wherein the memory is used to store 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 the financial platform task processing method described in any one of claims 1 to 7.
Citation Information
Cited By
Information queue management method and system on wireless communication network, product and medium
CN119012375A
Information queue management method, system, product and medium on wireless communication network
CN119012375B
