A task processing method, device, computer equipment and storage medium

By storing and processing tasks from different channels in the task table and configuring processing parameters according to task status and requirements, the code redundancy caused by channel differences is solved, and the efficiency and scalability of task processing is improved.

CN114168345BActive Publication Date: 2025-09-02PING AN PAY ELECTRONIC PAYMENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111544673.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-16
Publication Date
2025-09-02
Estimated Expiration
2041-12-16

AI Technical Summary

Technical Problem

In the prior art, due to differences between channels, file processing requirements are different. As new channels increase, the amount of code corresponding to the processing method increases, resulting in difficult code maintenance and heavy functions.

Method used

By receiving tasks from multiple different channels, storing tasks and their attributes in a preset task table, determining the processing order based on the task status, and executing tasks by configuring matching processing parameters to reduce redundant code.

Benefits of technology

It realizes simplified and efficient execution of task processing methods, reduces code redundancy, and improves the scalability and efficiency of task processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114168345B_ABST
    Figure CN114168345B_ABST
Patent Text Reader

Abstract

The present invention discloses a task processing method, apparatus, computer equipment, and storage medium, relating to the field of computer technology, including: receiving multiple tasks from multiple different channels, storing the multiple tasks and the task attributes corresponding to each task in a preset task table; determining the processing order of each task according to the task status corresponding to each task in the task table, and distributing each task to multiple processing nodes according to the processing order; configuring processing parameters matching the task requirements according to the task requirements corresponding to the received target task through each processing node, and executing the target task according to the processing parameters. The technical solution of the embodiment of the present invention can reduce the redundant code of the task processing method and improve the execution efficiency of the task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a task processing method, apparatus, computer equipment, and storage medium. Background Art

[0002] With the continuous development of computer networks, most user activities can be carried out through computer networks. For example, users can use computer devices to process files from multiple channels. However, since multiple files come from different channels, the processing method for each file may also be different.

[0003] In existing methods, when processing multiple files, a matching processing method is typically constructed based on the processing requirements of each file, and then the processing of each file is completed using this processing method. For example, when receiving a new file from a new channel, due to differences in the file processing requirements between channels, the business domain needs to construct a matching processing method based on the corresponding requirements to adapt the new file.

[0004] However, in the existing methods, as new channels are added, the amount of code corresponding to the processing method will increase, resulting in the phenomenon that the code is difficult to maintain and the functions are heavy. Summary of the Invention

[0005] The embodiments of the present invention provide a task processing method, apparatus, computer equipment and storage medium, which can reduce redundant codes in task processing and improve task execution efficiency.

[0006] In a first aspect, an embodiment of the present invention provides a task processing method, including:

[0007] Receiving multiple tasks from multiple different channels, and storing the multiple tasks and task attributes corresponding to each task in a preset task table; the task attributes include: task status and task requirements matching the channel;

[0008] Determining a processing order for each task according to a task status corresponding to each task in the task table, and distributing each task to multiple processing nodes according to the processing order;

[0009] Through each of the processing nodes, according to the task requirements corresponding to the received target task, processing parameters matching the task requirements are configured, and the target task is executed according to the processing parameters.

[0010] In a second aspect, an embodiment of the present invention further provides a task processing device, the device comprising:

[0011] A task receiving module is used to receive multiple tasks from multiple different channels and store the multiple tasks and the task attributes corresponding to each task in a preset task table; the task attributes include: task status and task requirements matching the channel;

[0012] A task distribution module, configured to determine a processing order for each task according to a task status corresponding to each task in the task table, and distribute each task to a plurality of processing nodes according to the processing order;

[0013] The task execution module is used to configure processing parameters matching the task requirements according to the task requirements corresponding to the received target task through each of the processing nodes, and execute the target task according to the processing parameters.

[0014] In a third aspect, an embodiment of the present invention further provides a computer device, the computer device comprising:

[0015] one or more processors;

[0016] a storage device for storing one or more computer programs;

[0017] When the one or more computer programs are executed by the one or more processors, so that the one or more processors execute the computer programs, the task processing method provided by any embodiment of the present invention is provided.

[0018] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the task processing method provided by any embodiment of the present invention is implemented.

[0019] The technical solution provided by the embodiment of the present invention receives multiple tasks from multiple different channels, stores the multiple tasks and the task attributes corresponding to each task in a preset task table, determines the processing order of each task according to the task status corresponding to each task in the task table, and distributes each task to multiple processing nodes according to the processing order. Through each processing node, according to the task requirements corresponding to the received target task, processing parameters matching the task requirements are configured, and the target task is executed according to the processing parameters. This technical means can reduce redundant code in the task processing method and improve the execution efficiency of tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 is a flowchart of a task processing method provided by one embodiment of the present invention;

[0021] Figure 2is a flowchart of a task processing method in another embodiment of the present invention;

[0022] Figure 3 is a flowchart of a task processing method in another embodiment of the present invention;

[0023] Figure 4 is a structural diagram of a task processing device in another embodiment of the present invention;

[0024] Figure 5 It is a structural diagram of a computer device in another embodiment of the present invention. DETAILED DESCRIPTION

[0025] Embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of protection of the present invention.

[0026] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0027] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.

[0028] It should be noted that the concepts of "first" and "second" mentioned in the present invention are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0029] It should be noted that the modifications of "one" and "multiple" mentioned in the present invention are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0030] The names of the messages or information exchanged between multiple devices in the embodiments of the present invention are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0031] In the related art, when processing multiple files, a matching processing method is usually constructed according to the processing requirements corresponding to each file, and then the processing of each file is completed through the processing method.

[0032] However, due to the differences between channels, the requirements for file processing are different. The relevant technology requires the business domain to build a matching processing method according to the corresponding requirements to adapt to the new files. As new channels are added, the amount of code corresponding to the processing method will increase, so the code will be difficult to maintain and the functions will be heavy.

[0033] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. 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 achieve optimal results.

[0034] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.

[0035] Figure 1 A flowchart of a task processing method provided in accordance with one embodiment of the present invention is provided. This embodiment of the present invention is applicable to situations where tasks from different channels are executed. The method can be performed by a task processing device, which can be composed of hardware and / or software and can generally be integrated into a computer device. The computer device can be an independent server or terminal device, or a cloud server or cloud terminal that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0036] like Figure 1 As shown, the method specifically includes the following steps:

[0037] Step 110: Receive multiple tasks from multiple different channels, and store the multiple tasks and the task attributes corresponding to each task in a preset task table; the task attributes include: task status and task requirements matching the channel.

[0038] In this embodiment, the channel may be a source of tasks, specifically a business module used to generate tasks, such as a year-end bonus activity module or a member wealth statistics module in an application. The tasks may include file processing tasks, data statistics tasks, and file storage tasks, and this embodiment does not limit the task types.

[0039] In a specific embodiment, a preset interface may be used to receive tasks sent from different channels, and each of the tasks and corresponding task attributes may be uniformly stored in a preset task table.

[0040] In this embodiment, when the business module sends a task to the task receiving end, it may also send the task attributes corresponding to the task (including task status, task requirements, and task path, etc.) to the task receiving end. The task status may indicate the current processing status of the task, such as initialization, processing, termination, and special.

[0041] In a specific embodiment, if the task status of the task is initialized, it can be understood that the task has never been processed; if the task status of the task is processing, it can be understood that the task has started to be processed but has not been completed; if the task status of the task is terminated, it can be understood that the task does not need to be processed; if the task status of the task is special, it can be understood that the task requires special processing (such as repairing a fault in the task, etc.).

[0042] In this embodiment, the task requirement of the task can be understood as the requirement of the business module for the processing node to perform what kind of processing on the task, such as storing, calculating, sending or other processing on the task; the task path of the task can be understood as the sending path corresponding to the task.

[0043] Step 120: Determine the processing order of each task according to the task status corresponding to each task in the task table, and distribute each task to multiple processing nodes according to the processing order.

[0044] In this embodiment, the processing order of each task can be determined based on the task status (e.g., initialization, processing, or special) corresponding to each task in the task table. Optionally, multiple processing batches can be set based on the task status corresponding to each task. Specifically, the first processing batch is used to process tasks with a task status of processing, the second processing batch is used to process tasks with a task status of initialization, and the third processing batch is used to process tasks with a task status of special. Then, according to the processing order of the above three batches, the multiple tasks corresponding to each batch are distributed to multiple processing nodes in sequence.

[0045] Step 130 : configuring processing parameters matching the received task requirements corresponding to the target task through each of the processing nodes, and executing the target task according to the processing parameters.

[0046] In this embodiment, before receiving multiple tasks from multiple different channels, a processing method that matches the requirements of each task can be pre-set. After the processing node obtains the target task to be executed, it can obtain a processing method that matches the task requirements included in the task attributes of the target task. Then, it configures the processing parameters in the processing method based on the task attributes corresponding to the target task (such as the task path) and executes the target task according to the configured processing parameters.

[0047] The advantage of this setting is that there is no need to build a matching processing method for each task. Different tasks from multiple different channels can be processed through a unified processing method, thereby reducing redundant code in the task processing method and making the task processing method easier to expand; secondly, by storing multiple tasks and corresponding task attributes in a task table, it is convenient to manage multiple tasks and improve the execution efficiency of tasks.

[0048] The technical solution provided by the embodiment of the present invention receives multiple tasks from multiple different channels, stores the multiple tasks and the task attributes corresponding to each task in a preset task table, determines the processing order of each task according to the task status corresponding to each task in the task table, and distributes each task to multiple processing nodes according to the processing order. Through each processing node, according to the task requirements corresponding to the received target task, processing parameters matching the task requirements are configured, and the target task is executed according to the processing parameters. This technical means can reduce redundant code in the task processing method and improve the execution efficiency of tasks.

[0049] Another embodiment of the present invention provides a task processing method. This embodiment is based on the above embodiment and specifically introduces a method for determining the processing order of each task according to the task status corresponding to each task in the task table.

[0050] Figure 2 This is a flowchart of a task processing method provided by another embodiment of the present invention. This embodiment, based on the above technical solution, provides a task processing method, which includes:

[0051] Step 210: Receive multiple tasks from multiple different channels, and store the multiple tasks and the task attributes corresponding to each task in a preset task table; the task attributes include: task status and task requirements matching the channel.

[0052] In one implementation of an embodiment of the present invention, receiving multiple tasks from multiple different channels includes: receiving multiple current business messages from multiple different channels; determining whether each of the current business messages is consistent with a historical business message; if not, parsing each of the current business messages to obtain a task corresponding to each of the current business messages, and a task attribute corresponding to each of the tasks; wherein each business message includes a data file to be processed.

[0053] In this embodiment, the business module can also use message notification to send tasks to the task receiving end. Each business message can include a data file to be processed. The data file can include a data file in Excel format and a data file in text format (TXT), etc. This embodiment does not limit the file format of the data file.

[0054] To avoid duplicate task reception, the task receiving end can compare the received current business message with each of the historical business messages (i.e., each business message received before the current time). If there is a historical business message that is consistent with the current business message, the current business message will not be processed; if there is no historical business message that is consistent with the current business message, the current business message will be parsed to obtain the task corresponding to the current business message and the task attributes corresponding to the task. The advantage of this setting is that it can prevent the processing of duplicate tasks and avoid wasting processing resources.

[0055] In a specific embodiment, the current business message can be parsed using a preset identifier to obtain a corresponding task and the task attributes corresponding to the task. The task includes a corresponding data file, and the task attributes may include the file type, file path, task requirements (e.g., processing only the data file header, reading and storing the data file, reading and sending the data file, etc.), and task status.

[0056] Step 220: Divide the tasks in the task table into in-progress tasks and initial tasks according to the task status corresponding to each task in the task table.

[0057] Among them, the processing task is a task whose task status is processing; the initial task is a task whose task status is initial.

[0058] Step 230: Determine the processing order of each task according to the number of tasks in the process, the number of initial tasks, and a preset threshold.

[0059] In one implementation of this embodiment, the in-process tasks and initial tasks in the task table may be divided into multiple processing batches according to the order in which the tasks are added and a preset threshold, and the multiple tasks included in each processing batch are distributed to multiple processing nodes in sequence. The preset threshold may be the total number of processing nodes. The number of tasks included in each processing batch may be equal to the preset threshold.

[0060] The advantage of this setting is that it can realize asynchronous execution of multiple tasks, thereby saving the execution time of multiple tasks and improving the execution efficiency of multiple tasks.

[0061] Step 240: Distribute each of the tasks to multiple processing nodes according to the processing order.

[0062] Step 250: Configure processing parameters matching the received task requirements according to the task requirements corresponding to the received target task through each processing node, and execute the target task according to the processing parameters.

[0063] Step 260: Store the execution results of each task in the task table.

[0064] In this embodiment, after the processing node completes the execution of the task, it may also store the execution result of each task and the result type (such as success or failure) in the task table.

[0065] Step 270: If the result type corresponding to the execution result of the task is failure, determine the failure cause of the execution result according to the execution result, and adopt an execution strategy that matches the failure cause to continue executing the task.

[0066] In this embodiment, optionally, if the result type corresponding to the execution result of the task is failure, the execution result can be compared with a preset standard execution result (ie, a correct execution result), and the failure reason of the execution result can be determined based on the comparison result.

[0067] In a specific embodiment, if the reason for the failure of the execution result of the task is environmental reasons (such as poor network resources), the task can be automatically continued to be executed; if the reason for the failure of the execution result of the task is file reasons (such as file damage, loss, etc.), the data file corresponding to the business module can be manually regenerated and the task can be continued to be executed.

[0068] The technical solution provided by the embodiment of the present invention receives multiple tasks from multiple different channels, stores the multiple tasks and the task attributes corresponding to each task in a preset task table, divides the tasks in the task table into processing tasks and initial tasks according to the task status corresponding to each task in the task table, determines the processing order of each task according to the number of tasks of the processing tasks, the number of tasks of the initial tasks and a preset threshold, distributes each task to multiple processing nodes according to the processing order, configures processing parameters matching the task requirements according to the task requirements corresponding to the received target task through each processing node, executes the target task according to the processing parameters, and stores the execution results of each task in the task table. If the result type corresponding to the execution result of the task is failure, determines the failure cause of the execution result according to the execution result, and adopts an execution strategy matching the failure cause to continue executing the task. This technical means can reduce redundant code in the task processing method and improve the execution efficiency of the task.

[0069] Another embodiment of the present invention provides a task processing method. This embodiment is based on the above embodiment and specifically introduces a method for determining the processing order of each task based on the number of tasks in the processing, the number of initial tasks and a preset threshold.

[0070] Figure 3 This is a flowchart of a task processing method provided by another embodiment of the present invention. This embodiment, based on the above technical solution, provides a task processing method, which includes:

[0071] Step 310: Receive multiple tasks from multiple different channels, and store the multiple tasks and the task attributes corresponding to each task in a preset task table; the task attributes include: task status and task requirements matching the channel.

[0072] Step 320: Divide the tasks in the task table into in-progress tasks and initial tasks according to the task status corresponding to each task in the task table.

[0073] Step 330: When the number of tasks in process is greater than or equal to a preset threshold, a plurality of tasks in process are obtained from the task table according to the preset threshold, and each of the obtained tasks in process is used as a first processing batch.

[0074] In this step, a number of in-process tasks equal to a preset threshold value may be obtained from the task table, and each of the obtained in-process tasks may be used as a first processing batch.

[0075] The advantage of this setting is that tasks in the processing state can be executed first, thereby reducing the execution time of multiple tasks and improving the execution efficiency of multiple tasks.

[0076] Step 340: Count the target number of processing nodes in the idle state in real time, and determine the processing order of the remaining tasks in the task table and the initial task according to the target number.

[0077] In this embodiment, optionally, during the execution of the first processing batch by each processing node, a target number of processing nodes in an idle state may be counted in real time. If a processing node completes execution of the task being processed, the working state of the processing node changes from an occupied state to an idle state.

[0078] In one implementation of this embodiment, if the target number of processing nodes in idle state is greater than zero, the target number of tasks can be obtained in sequence from the remaining processing tasks and initial tasks in the task table in the order in which the tasks are added as the remaining processing batches.

[0079] In a specific embodiment, it is assumed that the following tasks are added to the task table (arranged in the order of addition): Task A (processing), Task B (initialization), Task C (processing), Task D (initialization), Task E (processing) and Task F (processing), and the preset threshold is 3, then Task A, Task C and Task E can be used as the first processing batch. During the execution of the first processing batch by the processing node, if it is detected that the working status of two processing nodes becomes idle at the same time, Task B and Task D can be used as the second processing batch, so that the above two processing nodes execute the second processing batch. During the execution of each task by each processing node, if it is detected that the working status of one processing node becomes idle, Task F can be used as the third processing batch, so that the processing node executes the third processing batch.

[0080] The advantage of this setting is that by counting the target number of processing nodes in the idle state in real time, and obtaining the remaining processing tasks and initial tasks from the task table in sequence according to the target number, it is possible to avoid the processing nodes being idle for a long time, thereby improving the processing efficiency of the processing nodes for tasks.

[0081] In another implementation of this embodiment, the target number of processing nodes whose working status is idle is counted in real time, and the processing order of the remaining processing tasks and the initial tasks in the task table is determined according to the target number, including: real-time counting of the target number of processing nodes whose working status is idle, and when the number of remaining processing tasks in the task table is less than or equal to the target number, obtaining the remaining processing tasks from the task table as the second processing batch; according to the preset threshold, obtaining multiple initial tasks from the task table in sequence as the remaining processing batches.

[0082] In a specific embodiment, it is assumed that the following tasks are added to the task table (arranged in the order of addition): Task A (processing), Task B (initialization), Task C (processing), Task D (initialization), Task E (processing), Task F (processing) and Task G (initialization), and the preset threshold is 3, then Task A, Task C and Task E can be used as the first processing batch. During the execution of the first processing batch by the processing node, if it is detected that the working status of one or two processing nodes has become idle, Task F can be used as the second processing batch so that the idle processing node executes the second processing batch. During the execution of each task by each processing node, if it is detected that the working status of all processing nodes has become idle, Task B, Task D and Task G can be used as the third processing batch so that each processing node executes the third processing batch.

[0083] The advantage of this setting is that if there are both unexecuted in-process tasks and initial tasks in the task table, the in-process tasks will be executed first, and the initial task will be executed only after ensuring that all in-process tasks have been executed. In this way, tasks in the in-process status can be executed first, reducing the execution time of multiple tasks and improving the execution efficiency of multiple tasks.

[0084] In this embodiment, optionally, obtaining a plurality of initial tasks from the task table includes: randomly obtaining a plurality of initial tasks from the task table according to a preset random algorithm.

[0085] Among them, since the state of each initial task is an initialized state, the initial tasks to be executed are obtained in a random manner, so that each initial task can be processed fairly.

[0086] Step 350: Distribute each of the tasks to multiple processing nodes according to the processing order.

[0087] Step 360: Configure processing parameters matching the received task requirements according to the task requirements corresponding to the received target task through each of the processing nodes, and execute the target task according to the processing parameters.

[0088] In one implementation of this embodiment, each of the processing nodes is configured with processing parameters that match the task requirements according to the task requirements corresponding to the received target task, and the target task is executed according to the processing parameters, including: each of the processing nodes is configured with processing parameters that match the task requirements according to the task requirements corresponding to each of the initial tasks, the initial task is executed according to the processing parameters, and the task status of each of the initial tasks is changed to processing in the task table.

[0089] In this embodiment, after the processing node executes the initial task, it can change the task status of the initial task to "processing" in the task table. The advantage of this setting is that after receiving new tasks sent by new channels, the processing node can complete the execution of each task according to the updated task status.

[0090] In one implementation of this embodiment, after the tasks in the task table are divided into in-process tasks and initial tasks through step 320, if the number of tasks in the in-process tasks is less than a preset threshold, all the in-process tasks are obtained from the task table, and based on the number of the in-process tasks and the preset threshold, the initial tasks are obtained from the task table, and the obtained in-process tasks and initial tasks are used as the first processing batch; then the target number of processing nodes whose working status is idle is counted in real time, and the processing order of the remaining initial tasks in the task table is determined according to the target number.

[0091] If the number of tasks being processed in the task table is less than a preset threshold, all tasks being processed can be acquired, and the difference between the preset threshold and the number of tasks being processed can be calculated, and this difference can be used as the number of initial tasks to be acquired. During the execution of the first processing batch by the processing node, if the number of initial tasks remaining in the task table is less than or equal to the target number, all the initial tasks remaining in the task table can be acquired and used as the second processing batch; if the number of initial tasks remaining in the task table is greater than the target number, the target number of initial tasks can be acquired from the task table in sequence according to the order in which the tasks were added.

[0092] In a specific embodiment, assuming that the following tasks are added to the task table (arranged in the order of addition): Task A (processing), Task B (initialization), Task C (initialization), Task D (initialization) and Task E (processing), and the preset threshold is 3, then Task A, Task E and Task B can be used as the first processing batch. During the execution of the first processing batch by the processing node, if it is detected that the working status of two processing nodes has become idle at the same time, Task C and Task D can be used as the second processing batch, so that the above two processing nodes execute the second processing batch.

[0093] In another specific embodiment, during the execution of the first processing batch by the processing node, if it is detected that the working status of a processing node has become idle, task C can be used as the second processing batch to enable the processing node to execute the second processing batch. During the execution of each task by each processing node, if it is detected that the working status of a processing node has become idle, task D can be used as the third processing batch to enable the processing node to execute the third processing batch.

[0094] The technical solution provided by an embodiment of the present invention receives multiple tasks from multiple different channels, stores the multiple tasks and the task attributes corresponding to each task in a preset task table, divides the tasks in the task table into processing tasks and initial tasks according to the task status corresponding to each task in the task table, and when the number of tasks of the processing tasks is greater than or equal to a preset threshold, obtains multiple processing tasks from the task table according to the preset threshold, and uses each of the obtained processing tasks as the first processing batch, counts the target number of processing nodes with an idle working status in real time, determines the processing order of the remaining processing tasks and the initial tasks in the task table according to the target number, distributes each task to multiple processing nodes according to the processing order, configures processing parameters matching the task requirements according to the task requirements corresponding to the received target task through each processing node, and executes the target task according to the processing parameters. This technical means can reduce redundant code in the task processing method and improve the execution efficiency of the task.

[0095] Figure 4 FIG. 1 is a structural diagram of a task processing device provided by another embodiment of the present invention. Figure 4 As shown, the device includes: a task receiving module 410, a task distributing module 420 and a task executing module 430.

[0096] The task receiving module 410 is configured to receive multiple tasks from multiple different channels and store the multiple tasks and the task attributes corresponding to each task in a preset task table; the task attributes include: task status and task requirements matching the channel;

[0097] The task distribution module 420 is used to determine the processing order of each task according to the task status corresponding to each task in the task table, and distribute each task to multiple processing nodes according to the processing order;

[0098] The task execution module 430 is used to configure processing parameters matching the task requirements according to the task requirements corresponding to the received target task through each of the processing nodes, and execute the target task according to the processing parameters.

[0099] The technical solution provided by the embodiment of the present invention receives multiple tasks from multiple different channels, stores the multiple tasks and the task attributes corresponding to each task in a preset task table, determines the processing order of each task according to the task status corresponding to each task in the task table, and distributes each task to multiple processing nodes according to the processing order. Through each processing node, according to the task requirements corresponding to the received target task, processing parameters matching the task requirements are configured, and the target task is executed according to the processing parameters. This technical means can reduce redundant code in the task processing method and improve the execution efficiency of tasks.

[0100] Optionally, the task receiving module 410 includes:

[0101] A message receiving unit, configured to receive multiple current business messages from multiple different channels;

[0102] A message judging unit, configured to judge whether each current service message is consistent with a historical service message;

[0103] a message parsing unit, configured to parse each current business message when the current business message is inconsistent with the historical business message, to obtain a task corresponding to each current business message and a task attribute corresponding to each task;

[0104] Each business message includes a data file to be processed.

[0105] The task distribution module 420 includes:

[0106] A task division unit, configured to divide the tasks in the task table into in-process tasks and initial tasks according to the task status corresponding to each task in the task table;

[0107] An order determining unit, configured to determine a processing order of each of the tasks according to the number of tasks being processed, the number of tasks of the initial task, and a preset threshold;

[0108] a processing task acquisition unit, configured to, when the number of the processing tasks is greater than or equal to a preset threshold, acquire a plurality of processing tasks from the task table according to the preset threshold, and use each of the processing tasks as a first processing batch;

[0109] a target number counting unit, configured to count in real time the target number of processing nodes in an idle state, and determine the processing order of the remaining tasks in the task table and the initial tasks according to the target number;

[0110] A processing node statistics unit is used to count the target number of processing nodes in the idle state in real time;

[0111] a remaining processing task acquisition unit, configured to acquire the remaining processing tasks from the task table as a second processing batch when the number of the remaining processing tasks in the task table is less than or equal to the target number;

[0112] an initial task acquisition unit, configured to sequentially acquire a plurality of initial tasks from the task table as remaining processing batches according to the preset threshold;

[0113] The random acquisition unit is used to randomly acquire a plurality of initial tasks from the task table according to a preset random algorithm.

[0114] The task execution module 430 includes:

[0115] a state changing unit, configured to configure, through each processing node, processing parameters matching the task requirements corresponding to each initial task according to the task requirements, execute the initial task according to the processing parameters, and change the task status of each initial task to "processing" in the task table;

[0116] An execution result storage unit, configured to store the execution result corresponding to each task in the task table;

[0117] The cause determination unit is configured to determine the failure cause of the execution result according to the execution result if the result type corresponding to the execution result of the task is failure, and adopt an execution strategy matching the failure cause to continue executing the task.

[0118] The above device can execute the methods provided by all the above embodiments of the present invention, and has the corresponding functional modules and beneficial effects of executing the above methods. For technical details not fully described in the embodiments of the present invention, please refer to the methods provided by all the above embodiments of the present invention.

[0119] Figure 5 A schematic diagram of the structure of a computer device provided in another embodiment of the present invention is shown in FIG. Figure 5 As shown, the computer device includes a processor 510, a memory 520, an input device 530, and an output device 540; the number of processors 510 in the computer device can be one or more. Figure 5 In the figure, a processor 510 is used as an example; the processor 510, memory 520, input device 530 and output device 540 in the computer device can be connected via a bus or other means. Figure 5 The example of the connection via bus is taken. The memory 520, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as a computer program / module corresponding to a task processing method in any embodiment of the present invention (for example, a task receiving module 410, a task distribution module 420 and a task execution module 430 in a task processing device). The processor 510 executes various functional applications and data processing of the computer device by running the software programs, computer programs and modules stored in the memory 520, that is, implements the above-mentioned task processing method. That is, when the computer program is executed by the processor, it implements:

[0120] Receiving multiple tasks from multiple different channels, and storing the multiple tasks and task attributes corresponding to each task in a preset task table; the task attributes include: task status and task requirements matching the channel;

[0121] Determining a processing order for each task according to a task status corresponding to each task in the task table, and distributing each task to multiple processing nodes according to the processing order;

[0122] Through each of the processing nodes, according to the task requirements corresponding to the received target task, processing parameters matching the task requirements are configured, and the target task is executed according to the processing parameters.

[0123] The memory 520 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data generated based on the terminal's usage, etc. Furthermore, the memory 520 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some instances, the memory 520 may further include memory remotely located relative to the processor 510, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof. The input device 530 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the computer device, and may include, for example, a keyboard and a mouse. The output device 540 may include a display device such as a display screen.

[0124] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any embodiment of the present invention. Of course, a computer-readable storage medium provided by an embodiment of the present invention can perform the relevant operations of a task processing method provided by any embodiment of the present invention. That is, when the computer program is executed by a processor, it implements:

[0125] Receiving multiple tasks from multiple different channels, and storing the multiple tasks and task attributes corresponding to each task in a preset task table; the task attributes include: task status and task requirements matching the channel;

[0126] Determining a processing order for each task according to a task status corresponding to each task in the task table, and distributing each task to multiple processing nodes according to the processing order;

[0127] Through each of the processing nodes, according to the task requirements corresponding to the received target task, processing parameters matching the task requirements are configured, and the target task is executed according to the processing parameters.

[0128] Through the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented with the help of software and necessary general-purpose hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0129] It is worth noting that in the embodiment of the above-mentioned task processing device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0130] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.

Claims

1. A task processing method, characterized in that: The method comprises: Receiving multiple tasks from multiple different channels, and storing the multiple tasks and task attributes corresponding to each task in a preset task table; the task attributes include: task status and task requirements matching the channel; Determining a processing order for each task according to a task status corresponding to each task in the task table, and distributing each task to multiple processing nodes according to the processing order; By means of each of the processing nodes, according to the task requirements corresponding to the received target task, processing parameters matching the task requirements are configured, and the target task is executed according to the processing parameters; The channel refers to a business module used to generate tasks; The task status indicates the current processing status of the task, including initialization, processing, termination and special; The task requirement is a requirement for what kind of processing needs to be performed on the task.

2. The method according to claim 1, characterized in that Receive multiple tasks from a number of different channels, including: Receive multiple current business messages from multiple different channels; Determining whether each of the current service messages is consistent with the historical service messages; If not, then parse each of the current business messages to obtain tasks corresponding to each of the current business messages and task attributes corresponding to each of the tasks; Each business message includes a data file to be processed.

3. The method according to claim 1, characterized in that Determining the processing order of each task according to the task status corresponding to each task in the task table includes: According to the task status corresponding to each task in the task table, the tasks in the task table are divided into processing tasks and initial tasks; The processing order of each of the tasks is determined according to the task number of the task being processed, the task number of the initial task, and a preset threshold, wherein the preset threshold is the total number of processing nodes.

4. The method according to claim 3, characterized in that Determining a processing order of the tasks according to the number of tasks being processed, the number of tasks of the initial task, and a preset threshold, including: When the number of tasks in process is greater than or equal to a preset threshold, obtaining a plurality of tasks in process from the task table according to the preset threshold, and using the obtained tasks in process as a first processing batch; A target number of processing nodes in an idle state is counted in real time, and a processing order of the remaining processing tasks and the initial tasks in the task table is determined according to the target number.

5. The method according to claim 4, characterized in that Counting the target number of processing nodes in an idle state in real time, and determining the processing order of the remaining processing tasks and the initial tasks in the task table according to the target number, including: Real-time statistics of the target number of processing nodes in the idle state; When the number of tasks being processed remaining in the task table is less than or equal to the target number, obtaining the remaining tasks being processed from the task table as a second processing batch; According to the preset threshold, a plurality of initial tasks are sequentially obtained from the task table as remaining processing batches.

6. The method according to claim 5, characterized in that Acquire multiple initial tasks from the task table, including: According to a preset random algorithm, a plurality of initial tasks are randomly obtained from the task table; The process includes configuring, by each processing node, processing parameters matching the received task requirements corresponding to the target task, and executing the target task according to the processing parameters, including: Through each of the processing nodes, according to the task requirements corresponding to each of the initial tasks, processing parameters matching the task requirements are configured, the initial tasks are executed according to the processing parameters, and the task status of each of the initial tasks is changed to being processed in the task table.

7. The method according to claim 1, characterized in that After configuring, through each processing node, processing parameters matching the task requirements according to the received task requirements corresponding to the target task, and executing the target task according to the processing parameters, the method further includes: Storing the execution results of each task in the task table; If the result type corresponding to the execution result of the task is failure, the failure reason of the execution result is determined according to the execution result, and an execution strategy matching the failure reason is adopted to continue executing the task.

8. A task processing device, characterized in that: The device comprises: A task receiving module is used to receive multiple tasks from multiple different channels and store the multiple tasks and the task attributes corresponding to each task in a preset task table; the task attributes include: task status and task requirements matching the channel; A task distribution module, configured to determine a processing order for each task according to a task status corresponding to each task in the task table, and distribute each task to a plurality of processing nodes according to the processing order; A task execution module is used to configure processing parameters matching the task requirements according to the task requirements corresponding to the received target task through each of the processing nodes, and execute the target task according to the processing parameters; The channel refers to a business module used to generate tasks; The task status indicates the current processing status of the task, including initialization, processing, termination and special; The task requirement is a requirement for what kind of processing needs to be performed on the task.

9. A computer device comprising: one or more processors; a storage device for storing one or more computer programs; When the one or more computer programs are executed by the one or more processors, the task processing method according to any one of claims 1 to 7 is implemented when the one or more processors execute the computer programs.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the task processing method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Method and device for constructing Hadoop application development frame, and electronic device

    CN105045602A

  • An asynchronous task scheduling method and device

    CN109766172A