CN113703933A - Task processing method and device - Google Patents

Task processing method and device Download PDF

Info

Publication number
CN113703933A
CN113703933A CN202010440988.9A CN202010440988A CN113703933A CN 113703933 A CN113703933 A CN 113703933A CN 202010440988 A CN202010440988 A CN 202010440988A CN 113703933 A CN113703933 A CN 113703933A
Authority
CN
China
Prior art keywords
task
processing
target
task processing
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010440988.9A
Other languages
Chinese (zh)
Inventor
李宝刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202010440988.9A priority Critical patent/CN113703933A/en
Publication of CN113703933A publication Critical patent/CN113703933A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application

Abstract

The invention discloses a task processing method and a task processing device, and relates to the technical field of computers. One embodiment of the method comprises: determining a target task according to the task state and the task type of the storage task; adjusting the task state of the target task from a to-be-processed state to a locked state; determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type; and calling the task processing interface to perform task processing on the target task according to the task processing mode, and adjusting the task state of the target task according to the task processing result. The embodiment improves the task processing efficiency, avoids the risk of task concurrent processing, simplifies the task processing flow and improves the expansibility of task processing logic.

Description

Task processing method and device
Technical Field
The invention relates to the technical field of computers, in particular to a task processing method and a task processing device.
Background
The task data stored in the database generally sets corresponding task processing business logic for subsequent processing. The existing method mainly adopts the steps of scanning a database according to query conditions indicated in task processing logic to obtain a corresponding task to be processed, and then performing corresponding business processing.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
1. the task data is generally stored in the same task table in the database, and the processing efficiency is lower along with the increase of the task quantity;
2. the task processing equipment cannot be flexibly set, and the risk of concurrent processing of tasks exists;
3. the expansibility of the task processing logic is poor, and the task processing flow is complex.
Disclosure of Invention
In view of this, embodiments of the present invention provide a task processing method, which can improve task processing efficiency, avoid the risk of task concurrent processing, simplify task processing flow, and improve the expansibility of task processing logic.
To achieve the above object, according to a first aspect of an embodiment of the present invention, there is provided a task processing method including:
determining a target task according to the task state and the task type of the storage task;
adjusting the task state of the target task from a to-be-processed state to a locked state;
determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type;
and calling the task processing interface to perform task processing on the target task according to the task processing mode, and adjusting the task state of the target task according to the task processing result.
Further, the step of determining the target task according to the task state and the task type of the storage task comprises: and determining alternative target tasks according to the task states of the storage tasks, and determining the target tasks according to the task types of the alternative target tasks, wherein the task number of the target tasks is consistent with the number of the alternative target tasks with the same task type.
Further, when the number of the target tasks is multiple, before the step of calling the task processing interface to perform task processing on the target tasks according to the task processing mode, the task processing method further includes: and placing a plurality of target tasks in a locked state in the same queue.
Further, the step of calling the task processing interface to perform task processing on the target task according to the task processing mode comprises the following steps: and determining corresponding task processing equipment from the idle task processing equipment set according to the task type of the target task, and calling a task processing interface by using the task processing equipment to perform task processing on the target task according to a corresponding task processing mode.
Further, the task processing method further comprises the following steps: setting a processing frequency threshold and a locking time threshold, and determining that the processing of the task processing result fails under the condition that the processing frequency of the same target task exceeds the processing frequency threshold; and when the locking state of the target task exceeds the locking time threshold value, releasing the locking state of the target task.
Further, the task processing method further comprises the following steps: and setting a storage task quantity threshold and/or a processing time threshold, and performing removal processing on the storage task in the task state of being processed according to the storage task quantity threshold and/or the processing time threshold.
Further, in the case that the task type corresponding to the storage task is the newly added task type, the task processing method further includes: and configuring a corresponding task processing interface for the newly added task type.
According to a second aspect of the embodiments of the present invention, there is provided a task processing apparatus including:
the target task determining module is used for determining a target task according to the task state and the task type of the storage task;
the task state adjusting module is used for adjusting the task state of the target task from a to-be-processed state to a locked state;
the task processing interface determining module is used for determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type;
and the task processing module is used for calling the task processing interface to perform task processing on the target task according to the task processing mode and adjusting the task state of the target task according to the task processing result.
According to a third aspect of embodiments of the present invention, there is provided an electronic apparatus, including:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement any of the task processing methods described above.
According to a fourth aspect of embodiments of the present invention, there is provided a computer-readable medium on which a computer program is stored, the program, when executed by a processor, implementing any one of the task processing methods described above.
One embodiment of the above invention has the following advantages or benefits: the target task is determined according to the task state and the task type of the storage task; adjusting the task state of the target task from a to-be-processed state to a locked state; determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type; the technical means that the task processing interface is called to perform task processing on the target task according to the task processing mode and the task state of the target task is adjusted according to the task processing result are overcome, so that the technical problems that in the existing method, the task processing efficiency is low, task processing equipment cannot be flexibly set, the task concurrent processing risk exists, the expansibility of task processing logic is poor, and the task processing flow is complex are solved, and the technical effects of improving the task processing efficiency, avoiding the risk of task concurrent processing, simplifying the task processing flow and improving the expansibility of the task processing logic are achieved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of a main flow of a task processing method provided according to a first embodiment of the present invention;
fig. 2 is a schematic diagram of a main flow of a task processing method provided according to a second embodiment of the present invention;
FIG. 3 is a schematic diagram of the main modules of a task processing device provided according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of a main flow of a task processing method provided according to a first embodiment of the present invention; as shown in fig. 1, a task processing method provided in an embodiment of the present invention mainly includes:
and step S101, determining a target task according to the task state and the task type of the storage task.
Specifically, according to the embodiment of the present invention, the method for acquiring the task state and the task type corresponding to the storage task may be: when the storage task is stored in the database, inserting a task record into a task table, wherein the task record is used for recording the task state of the storage task; a polling mechanism may also be used to set a polling period, and traverse the database (if all the storage tasks are stored in one task table, traverse the task table) according to the polling period to obtain the task state and the task type of the storage task.
Further, according to an embodiment of the present invention, the step of determining the target task according to the task state and the task type of the storage task includes: and determining alternative target tasks according to the task states of the storage tasks, and determining the target tasks according to the task types of the alternative target tasks, wherein the task number of the target tasks is consistent with the number of the alternative target tasks with the same task type.
The task state of the task is firstly stored as the alternative target task to be processed, and then the target task is determined according to the task type of the alternative target task, so that the alternative target tasks with the same target type are determined as the target task together, the target tasks with the same task type can be processed in batch, the task processing flow is further simplified, and the task processing efficiency is improved. It should be noted that, for an alternative target task without other same task types, it is directly determined as the target task.
And step S102, adjusting the task state of the target task from the to-be-processed state to the locked state.
The method can be realized by adopting a locking mechanism of a distributed system (such as a Redis (a distributed database and provides application program interfaces of multiple languages)) distributed lock, the target task is locked through the setting, and the corresponding task state is adjusted from the to-be-processed state to the locked state, so that the risk of task concurrent processing caused by simultaneous processing of the same target task by multiple task processing devices can be avoided, and the flexibility of the task processing devices is further improved.
Specifically, according to the embodiment of the present invention, in a case that the number of the target tasks is multiple, before the step of calling the task processing interface to perform task processing on the target tasks according to the task processing mode, the task processing method further includes: and placing a plurality of target tasks in a locked state in the same queue.
The number of the target tasks is consistent with the number of the alternative target tasks with the same task type, so that when the number of the target tasks is multiple, that is, when there are multiple target tasks with the same task type, the multiple locked target tasks with the same task type are placed in the same queue, and then the subsequently determined task processing device calls the corresponding task processing interface to perform batch processing on the multiple target tasks in the queue, so as to improve the task processing efficiency.
Step S103, determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type.
Specifically, according to the embodiment of the present invention, before the step of determining the target task according to the task state and the task type of the storage task, the task processing logic determines the corresponding task processing interface according to the common target task type to be processed, and configures the task processing mode corresponding to the specific task type for each task processing interface.
Further, according to an embodiment of the present invention, after the storing the task, the task processing further includes: and judging whether the task type corresponding to the warehoused storage task is a newly added task type (namely judging whether the task type corresponding to the warehoused storage task has a corresponding task processing interface), and if not, configuring a corresponding task processing interface according to the newly added task type.
Through the arrangement, the corresponding task processing interface is configured for the newly added task type, the task processing interface indicates a specific task processing mode, and the expansibility of task processing logic is improved.
And step S104, calling the task processing interface to perform task processing on the target task according to the task processing mode, and adjusting the task state of the target task according to the task processing result.
Specifically, according to an embodiment of the present invention, the step of the invoking task processing interface performing task processing on the target task according to the task processing mode includes: and determining corresponding task processing equipment from the idle task processing equipment set according to the task type of the target task, and calling a task processing interface by using the task processing equipment to perform task processing on the target task according to a corresponding task processing mode.
Through the arrangement, the task processing device dynamically calculates which task processing interface is called to perform task processing on the target task, and flexible calling of the task processing device is improved.
According to a specific implementation manner of the embodiment of the present invention, when the target task to be locked is a plurality of task types, one task processing interface is determined for each task type through the setting in the foregoing, then a plurality of task processing devices can be determined from the idle task processing device set, and one task processing interface is respectively taken and called to perform task processing on the target task of one task type.
According to a specific implementation manner of the embodiment of the present invention, before the step of invoking the task processing interface to perform task processing on the target task according to the corresponding task processing manner, the task processing method further includes: and determining that the target task is in a locking method.
Preferably, according to an embodiment of the present invention, the task processing method further includes: setting a processing frequency threshold and a locking time threshold, and determining that the processing of the task processing result fails under the condition that the processing frequency of the same target task exceeds the processing frequency threshold; and when the locking state of the target task exceeds the locking time threshold value, releasing the locking state of the target task.
By setting the processing frequency threshold, the phenomenon that the task processing interface and the corresponding task processing equipment are always temporarily used due to errors in the task processing execution process can be effectively avoided, and the task processing efficiency is reduced; by setting the locking time threshold, the situation that the locking mechanism is occupied for a long time due to the fact that the corresponding task state is forgotten to be adjusted after the task processing is finished is favorably reduced.
Further, according to an embodiment of the present invention, the task processing method further includes: and setting a storage task quantity threshold and/or a processing time threshold, and performing removal processing on the storage task in the task state of being processed according to the storage task quantity threshold and/or the processing time threshold.
Through the arrangement, the processed storage tasks are regularly cleaned, and the service processing efficiency is improved. It should be noted that, in the above-mentioned moving-out processing of the storage task completed by the processing, the storage task completed by the processing does not necessarily have to be deleted, and the storage task completed by the processing may also be moved out of the current task table, and may be transferred to the backup table so as to be called and queried subsequently.
According to the technical scheme of the embodiment of the invention, the target task is determined according to the task state and the task type of the storage task; adjusting the task state of the target task from a to-be-processed state to a locked state; determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type; the technical means that the task processing interface is called to perform task processing on the target task according to the task processing mode and the task state of the target task is adjusted according to the task processing result are overcome, so that the technical problems that in the existing method, the task processing efficiency is low, task processing equipment cannot be flexibly set, the task concurrent processing risk exists, the expansibility of task processing logic is poor, and the task processing flow is complex are solved, and the technical effects of improving the task processing efficiency, avoiding the risk of task concurrent processing, simplifying the task processing flow and improving the expansibility of the task processing logic are achieved.
Fig. 2 is a schematic diagram of a main flow of a task processing method provided according to a second embodiment of the present invention; as shown in fig. 2, an application scenario of the embodiment of the present invention is processing of a timing task corresponding to an order, and a task processing method provided by the embodiment of the present invention mainly includes:
step S201, determining an alternative target task according to the task state of the storage task, and determining the target task according to the task type of the alternative task.
Specifically, according to the embodiment of the present invention, when the timed task is stored in the timed task table in the database, a task record is inserted for recording the task state of the timed task. Before executing the task processing of the timed task, firstly, the timed task table needs to be traversed, the timed task with the task record as the waiting processing (WAIT) is obtained, and the storage task with the task state as the waiting processing is determined as the alternative target task. For the application scenario of processing the timing task corresponding to the order, the task type can be a new order task, a recharge task and the like.
Step S202, the task state of the target task is adjusted from the to-be-processed state to the locked state.
Specifically, the LOCK (locking method) provided by the basetask service can be realized by adopting an interface of the basetask to adjust the task state of the target task from the waiting processing (WAIT) to the locking state (LOCK).
Specifically, according to the embodiment of the present invention, in a case that the number of the target tasks is multiple, before the step of calling the task processing interface to perform task processing on the target tasks according to the task processing mode, the task processing method further includes: and placing a plurality of target tasks in a locked state in the same queue.
The number of the target tasks is consistent with the number of the alternative target tasks with the same task type, so that when the number of the target tasks is multiple, that is, when there are multiple target tasks with the same task type, the multiple locked target tasks with the same task type are placed in the same queue, and then the subsequently determined task processing device calls the corresponding task processing interface to perform batch processing on the multiple target tasks in the queue, so as to improve the task processing efficiency.
Step S203, determining a task processing interface according to the task type of the target task, where the task processing interface indicates a task processing manner indicated by the specific task type.
Specifically, a specific task processing interface task execution service is obtained by calculating according to a task type of a target task according to an interface implementation class (task scheduling) of a basic task, and the task processing interface indicates a task processing mode corresponding to the specific task type.
According to the embodiment of the invention, before the step of determining the target task according to the task state and the task type of the storage task, the task processing logic determines the corresponding task processing interface according to the common target task type to be processed, and simultaneously configures the task processing mode corresponding to the specific task type for each task processing interface. According to a specific implementation manner of the embodiment of the present invention, the taskeexecutorservice (interface implementation class) is mainly used to implement two methods, a timed task type is defined for gettasktipeeneum, and the execute is responsible for executing task processing logic (i.e., a specific task processing manner) corresponding to a specific task type.
Further, according to an embodiment of the present invention, after the storing the task, the task processing further includes: and judging whether the task type corresponding to the warehoused storage task is a newly added task type (namely judging whether the task type corresponding to the warehoused storage task has a corresponding task processing interface), and if not, configuring a corresponding task processing interface according to the newly added task type.
Through the arrangement, the corresponding task processing interface is configured for the newly added task type, the task processing interface indicates a specific task processing mode, and the expansibility of task processing logic is improved.
And step S204, determining corresponding task processing equipment from the idle task processing equipment set according to the task type of the target task, and calling a task processing interface by using the task processing equipment to perform task processing on the target task according to a corresponding task processing mode.
According to a specific implementation manner of the embodiment of the present invention, before the step of invoking the task processing interface to perform task processing on the target task according to the corresponding task processing manner, the task processing method further includes: and determining that the target task is in a locking method.
Further, according to a specific implementation manner of the embodiment of the present invention, when the target task to be locked is a plurality of task types, one task processing interface is determined for each task type through the above setting, then a plurality of task processing devices can be determined from the idle task processing device set, and one task processing interface is respectively called to perform task processing on the target task of one task type.
And step S205, adjusting the task state of the target task according to the task processing result.
Specifically, according to a specific implementation manner of an embodiment of the present invention, according to the implementation class unlock of the basicktask, the task state of the target task recorded by the task is adjusted from the LOCK state (LOCK) to several situations such as WAIT for processing, LOCK, SUCCESS (processing completion), INVALID recording, and SUC-OVER (processing failure times exceed a threshold) according to the task processing result, and when in specific application, the specific situation included in the task state can be adjusted according to the actual situation.
Further, according to a specific implementation manner of the embodiment of the present invention, the Task interface implementation class Task service mainly implements two methods, lock is responsible for performing lock recording operation, and execute is responsible for summarizing and scheduling three methods of the basic Task interface, so as to complete the full-flow recording of executing a timing Task.
And step S206, setting a storage task quantity threshold and/or a processing time threshold, and performing removal processing on the storage task with the task state being the processing completion according to the storage task quantity threshold and/or the processing time threshold.
According to a specific implementation manner of the embodiment of the present invention, when the target task to be locked is a plurality of task types, one task processing interface is determined for each task type through the setting in the foregoing, then a plurality of task processing devices can be determined from the idle task processing device set, and one task processing interface is respectively taken and called to perform task processing on the target task of one task type.
According to the technical scheme of the embodiment of the invention, the target task is determined according to the task state and the task type of the storage task; adjusting the task state of the target task from a to-be-processed state to a locked state; determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type; the technical means that the task processing interface is called to perform task processing on the target task according to the task processing mode and the task state of the target task is adjusted according to the task processing result are overcome, so that the technical problems that in the existing method, the task processing efficiency is low, task processing equipment cannot be flexibly set, the task concurrent processing risk exists, the expansibility of task processing logic is poor, and the task processing flow is complex are solved, and the technical effects of improving the task processing efficiency, avoiding the risk of task concurrent processing, simplifying the task processing flow and improving the expansibility of the task processing logic are achieved.
FIG. 3 is a schematic diagram of the main modules of a task processing device provided according to an embodiment of the present invention; as shown in fig. 3, a task processing device 300 according to an embodiment of the present invention mainly includes:
and the target task determining module 301 is configured to determine a target task according to the task state and the task type of the storage task.
Specifically, according to an embodiment of the present invention, the task processing device 300 may further include a task state and task type obtaining module, configured to obtain the task state and the task type of the storage task, and specifically, the method for obtaining the task state and the task type corresponding to the storage task may be: when the storage task is stored in the database, inserting a task record into a task table, wherein the task record is used for recording the task state of the storage task; a polling mechanism may also be used to set a polling period, and traverse the database (if all the storage tasks are stored in one task table, traverse the task table) according to the polling period to obtain the task state and the task type of the storage task.
Further, according to the embodiment of the present invention, the target task determining module 301 is further configured to: and determining alternative target tasks according to the task states of the storage tasks, and determining the target tasks according to the task types of the alternative target tasks, wherein the task number of the target tasks is consistent with the number of the alternative target tasks with the same task type.
The task state of the task is firstly stored as the alternative target task to be processed, and then the target task is determined according to the task type of the alternative target task, so that the alternative target tasks with the same target type are determined as the target task together, the target tasks with the same task type can be processed in batch, the task processing flow is further simplified, and the task processing efficiency is improved. It should be noted that, for an alternative target task without other same task types, it is directly determined as the target task.
And a task state adjusting module 302, configured to adjust a task state of the target task from a pending state to a locked state.
Specifically, according to an embodiment of the present invention, the task processing device 300 further includes a target task locking module, where, when the number of the target tasks is multiple, the target task locking module is configured to, before the step of invoking the task processing interface to perform task processing on the target task according to the task processing manner: and placing a plurality of target tasks in a locked state in the same queue.
The number of the target tasks is consistent with the number of the alternative target tasks with the same task type, so that when the number of the target tasks is multiple, that is, when there are multiple target tasks with the same task type, the multiple locked target tasks with the same task type are placed in the same queue, and then the subsequently determined task processing device calls the corresponding task processing interface to perform batch processing on the multiple target tasks in the queue, so as to improve the task processing efficiency.
The task processing interface determining module 303 is configured to determine a task processing interface according to a task type of the target task, where the task processing interface indicates a task processing mode corresponding to the task type.
Specifically, according to an embodiment of the present invention, the task processing device 300 further includes a task processing interface configuration module, and before the step of determining the target task according to the task state and the task type of the storage task, the task processing interface configuration module is configured to: and determining corresponding task processing interfaces according to common target task types to be processed, and configuring a task processing mode corresponding to the specific task type for each task processing interface.
Further, according to the embodiment of the present invention, the task processing apparatus 300 further includes a newly added task type determining module, and after the storage task is put into the storage, the newly added task type determining module is configured to: and judging whether the task type corresponding to the warehousing storage task is a new task type (namely judging whether the task type corresponding to the warehousing storage task has a corresponding task processing interface), and if so, configuring a corresponding task processing interface according to the new task type, namely the task type corresponding to the warehousing storage task is the new task type.
Through the arrangement, the corresponding task processing interface is configured for the newly added task type, the task processing interface indicates a specific task processing mode, and the expansibility of task processing logic is improved.
And the task processing module 304 is configured to invoke the task processing interface to perform task processing on the target task according to the task processing mode, and adjust the task state of the target task according to the task processing result.
Specifically, according to an embodiment of the present invention, the task processing module 304 is further configured to: and determining corresponding task processing equipment from the idle task processing equipment set according to the task type of the target task, and calling a task processing interface by using the task processing equipment to perform task processing on the target task according to a corresponding task processing mode.
Through the arrangement, the task processing device dynamically calculates which task processing interface is called to perform task processing on the target task, and flexible calling of the task processing device is improved.
According to a specific implementation manner of the embodiment of the present invention, in a case that the target task to be locked is a plurality of task types, by setting in the foregoing, a task processing interface is determined for each task type, and the task processing module 304 is further configured to: and determining a plurality of task processing devices from the idle task processing device set, and respectively calling one task processing interface to perform task processing on a target task of one task type.
Preferably, according to the embodiment of the present invention, the task processing apparatus 300 further includes a processing time threshold and a locking time threshold setting module, configured to: setting a processing frequency threshold and a locking time threshold, and determining that the processing of the task processing result fails under the condition that the processing frequency of the same target task exceeds the processing frequency threshold; and when the locking state of the target task exceeds the locking time threshold value, releasing the locking state of the target task.
By setting the processing frequency threshold, the phenomenon that the task processing interface and the corresponding task processing equipment are always temporarily used due to errors in the task processing execution process can be effectively avoided, and the task processing efficiency is reduced; by setting the locking time threshold, the situation that the locking mechanism is occupied for a long time due to the fact that the corresponding task state is forgotten to be adjusted after the task processing is finished is favorably reduced.
Further, according to the embodiment of the present invention, the task processing apparatus 300 further includes a storage task number threshold and/or a processing time threshold setting module, configured to: and setting a storage task quantity threshold and/or a processing time threshold, and performing removal processing on the storage task in the task state of being processed according to the storage task quantity threshold and/or the processing time threshold.
Through the arrangement, the processed storage tasks are regularly cleaned, and the service processing efficiency is improved. It should be noted that, in the above-mentioned moving-out processing of the storage task completed by the processing, the storage task completed by the processing does not necessarily have to be deleted, and the storage task completed by the processing may also be moved out of the current task table, and may be transferred to the backup table so as to be called and queried subsequently.
According to the technical scheme of the embodiment of the invention, the target task is determined according to the task state and the task type of the storage task; adjusting the task state of the target task from a to-be-processed state to a locked state; determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type; the technical means that the task processing interface is called to perform task processing on the target task according to the task processing mode and the task state of the target task is adjusted according to the task processing result are overcome, so that the technical problems that in the existing method, the task processing efficiency is low, task processing equipment cannot be flexibly set, the task concurrent processing risk exists, the expansibility of task processing logic is poor, and the task processing flow is complex are solved, and the technical effects of improving the task processing efficiency, avoiding the risk of task concurrent processing, simplifying the task processing flow and improving the expansibility of the task processing logic are achieved.
Fig. 4 shows an exemplary system architecture 400 of a task processing method or a task processing device to which an embodiment of the present invention can be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405 (this architecture is merely an example, and the components included in a particular architecture may be adapted according to application specific circumstances). The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 401, 402, 403. The background management server may analyze and perform other processing on the received data such as the task state and the task type, and feed back a processing result (for example, a task processing interface, a task processing result — just an example) to the terminal device.
It should be noted that the task processing method provided by the embodiment of the present invention is generally executed by the server 405, and accordingly, the task processing device is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises a target task determining module, a task state adjusting module, a task processing interface determining module and a task processing module. The names of these modules do not in some cases constitute a limitation on the module itself, and for example, a task processing module may also be described as a "module of a task processing module".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: determining a target task according to the task state and the task type of the storage task; adjusting the task state of the target task from a to-be-processed state to a locked state; determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type; and calling the task processing interface to perform task processing on the target task according to the task processing mode, and adjusting the task state of the target task according to the task processing result.
According to the technical scheme of the embodiment of the invention, the target task is determined according to the task state and the task type of the storage task; adjusting the task state of the target task from a to-be-processed state to a locked state; determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type; the technical means that the task processing interface is called to perform task processing on the target task according to the task processing mode and the task state of the target task is adjusted according to the task processing result are overcome, so that the technical problems that in the existing method, the task processing efficiency is low, task processing equipment cannot be flexibly set, the task concurrent processing risk exists, the expansibility of task processing logic is poor, and the task processing flow is complex are solved, and the technical effects of improving the task processing efficiency, avoiding the risk of task concurrent processing, simplifying the task processing flow and improving the expansibility of the task processing logic are achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A task processing method, comprising:
determining a target task according to the task state and the task type of the storage task;
adjusting the task state of the target task from a to-be-processed state to a locked state;
determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type;
and calling the task processing interface to perform task processing on the target task according to the task processing mode, and adjusting the task state of the target task according to a task processing result.
2. The task processing method according to claim 1, wherein the step of determining the target task according to the task state and the task type of the storage task comprises: and determining alternative target tasks according to the task states of the storage tasks, and determining the target tasks according to the task types of the alternative target tasks, wherein the number of the target tasks is consistent with the number of the alternative target tasks with the same task type.
3. The task processing method according to claim 2, wherein when the number of the target tasks is plural, before the step of invoking the task processing interface to perform task processing on the target task according to the task processing manner, the task processing method further includes: and placing a plurality of target tasks in a locked state in the same queue.
4. The task processing method according to claim 1, wherein the step of invoking the task processing interface to perform task processing on the target task according to the task processing mode comprises: and determining corresponding task processing equipment from an idle task processing equipment set according to the task type of the target task, and calling the task processing interface by using the task processing equipment to perform task processing on the target task according to a corresponding task processing mode.
5. The task processing method according to claim 1, further comprising: setting a processing frequency threshold and a locking time threshold, and determining that the processing of the task processing result fails under the condition that the processing frequency of the same target task exceeds the processing frequency threshold; and under the condition that the locking state of the target task exceeds the locking time threshold, releasing the locking state of the target task.
6. The task processing method according to claim 1, further comprising: and setting a storage task quantity threshold and/or a processing time threshold, and performing removal processing on the storage task in the task state of being processed according to the storage task quantity threshold and/or the processing time threshold.
7. The task processing method according to claim 1, wherein when the task type corresponding to the storage task is a new task type, the task processing method further includes: and configuring a corresponding task processing interface for the newly added task type.
8. A task processing apparatus, comprising:
the target task determining module is used for determining a target task according to the task state and the task type of the storage task;
the task state adjusting module is used for adjusting the task state of the target task from a to-be-processed state to a locked state;
the task processing interface determining module is used for determining a task processing interface according to the task type of the target task, wherein the task processing interface indicates a task processing mode corresponding to the task type;
and the task processing module is used for calling the task processing interface to perform task processing on the target task according to the task processing mode and adjusting the task state of the target task according to a task processing result.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202010440988.9A 2020-05-22 2020-05-22 Task processing method and device Pending CN113703933A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010440988.9A CN113703933A (en) 2020-05-22 2020-05-22 Task processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010440988.9A CN113703933A (en) 2020-05-22 2020-05-22 Task processing method and device

Publications (1)

Publication Number Publication Date
CN113703933A true CN113703933A (en) 2021-11-26

Family

ID=78646252

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010440988.9A Pending CN113703933A (en) 2020-05-22 2020-05-22 Task processing method and device

Country Status (1)

Country Link
CN (1) CN113703933A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766129A (en) * 2016-08-17 2018-03-06 北京金山云网络技术有限公司 A kind of task processing method, apparatus and system
CN108710538A (en) * 2018-05-14 2018-10-26 中国平安人寿保险股份有限公司 A kind of thread configuration method, computer readable storage medium and terminal device
CN109308214A (en) * 2017-07-27 2019-02-05 北京京东尚科信息技术有限公司 Data task processing method and system
CN109634733A (en) * 2018-12-13 2019-04-16 成都四方伟业软件股份有限公司 Task scheduling and managing method, device and operation management server
CN110245011A (en) * 2018-03-08 2019-09-17 北京京东尚科信息技术有限公司 A kind of method for scheduling task and device
CN110443695A (en) * 2019-07-31 2019-11-12 中国工商银行股份有限公司 Data processing method and its device, electronic equipment and medium
CN110806933A (en) * 2019-11-05 2020-02-18 中国建设银行股份有限公司 Batch task processing method, device, equipment and storage medium
CN110928905A (en) * 2019-11-07 2020-03-27 泰康保险集团股份有限公司 Data processing method and device
CN110991808A (en) * 2019-11-06 2020-04-10 中国建设银行股份有限公司 Task allocation method and device

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766129A (en) * 2016-08-17 2018-03-06 北京金山云网络技术有限公司 A kind of task processing method, apparatus and system
CN109308214A (en) * 2017-07-27 2019-02-05 北京京东尚科信息技术有限公司 Data task processing method and system
CN110245011A (en) * 2018-03-08 2019-09-17 北京京东尚科信息技术有限公司 A kind of method for scheduling task and device
CN108710538A (en) * 2018-05-14 2018-10-26 中国平安人寿保险股份有限公司 A kind of thread configuration method, computer readable storage medium and terminal device
CN109634733A (en) * 2018-12-13 2019-04-16 成都四方伟业软件股份有限公司 Task scheduling and managing method, device and operation management server
CN110443695A (en) * 2019-07-31 2019-11-12 中国工商银行股份有限公司 Data processing method and its device, electronic equipment and medium
CN110806933A (en) * 2019-11-05 2020-02-18 中国建设银行股份有限公司 Batch task processing method, device, equipment and storage medium
CN110991808A (en) * 2019-11-06 2020-04-10 中国建设银行股份有限公司 Task allocation method and device
CN110928905A (en) * 2019-11-07 2020-03-27 泰康保险集团股份有限公司 Data processing method and device

Similar Documents

Publication Publication Date Title
CN112148711B (en) Batch processing task processing method and device
CN111277639B (en) Method and device for maintaining data consistency
CN111897633A (en) Task processing method and device
CN111831461A (en) Method and device for processing business process
CN112084042B (en) Message processing method and device
CN113742389A (en) Service processing method and device
CN113760924A (en) Distributed transaction processing method and device
CN113535420A (en) Message processing method and device
CN112398669A (en) Hadoop deployment method and device
CN113779122B (en) Method and device for exporting data
CN113703933A (en) Task processing method and device
CN115525411A (en) Method, device, electronic equipment and computer readable medium for processing service request
CN113760487A (en) Service processing method and device
CN114374657A (en) Data processing method and device
CN114064803A (en) Data synchronization method and device
CN109087097B (en) Method and device for updating same identifier of chain code
CN109213815B (en) Method, device, server terminal and readable medium for controlling execution times
CN113743630A (en) Method and device for executing intelligent call reservation
CN113760861A (en) Data migration method and device
CN113626176A (en) Service request processing method and device
CN112015565A (en) Method and device for determining task downloading queue
CN113157405A (en) Method and device for retrying breakpoint of business process
CN112579615A (en) Method and device for realizing distributed lock
CN112948430B (en) Date data query method and device
CN111415262A (en) Service processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination