CN113672357A - Task scheduling method, device and system - Google Patents

Task scheduling method, device and system Download PDF

Info

Publication number
CN113672357A
CN113672357A CN202010412494.XA CN202010412494A CN113672357A CN 113672357 A CN113672357 A CN 113672357A CN 202010412494 A CN202010412494 A CN 202010412494A CN 113672357 A CN113672357 A CN 113672357A
Authority
CN
China
Prior art keywords
task
processed
message
message queue
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
CN202010412494.XA
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 CN202010412494.XA priority Critical patent/CN113672357A/en
Publication of CN113672357A publication Critical patent/CN113672357A/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/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • 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/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a method, a device and a system for task scheduling, and relates to the technical field of computers. One embodiment of the method comprises: configuring task information of a task to be processed; generating a message queue message according to the task information of the task to be processed; and pushing the message queue message to a consuming end subscribing the message queue service, or responding to a message acquisition request of the consuming end to send the message queue message to the consuming end so that the consuming end processes the task to be processed according to the message queue message. The implementation mode realizes task scheduling by publishing the uniform subscription service, is convenient to maintain and simple to deploy, and can realize asynchronous decoupling of task configuration and processing.

Description

Task scheduling method, device and system
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, and a system for task scheduling.
Background
In the prior art, deployment under a micro-service deployment environment is complex, maintenance is difficult, configuration is not uniform, and development is complex. Multiple machine deployment is more difficult.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, and a system for task scheduling, where task scheduling is implemented by issuing a unified subscription service, maintenance is convenient, deployment is simple, and asynchronous decoupling of task configuration and processing can be implemented.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a task scheduling method, including:
configuring task information of a task to be processed;
generating a message queue message according to the task information of the task to be processed;
and pushing the message queue message to a consuming end subscribing the message queue service, or responding to a message acquisition request of the consuming end to send the message queue message to the consuming end so that the consuming end processes the task to be processed according to the message queue message.
Optionally, the task information includes task states, and the task states include a first task state and a second task state;
before generating a message queue message according to the task information of the task to be processed, the method further comprises the following steps: and determining the task state of the task to be processed as a first task state.
Optionally, the task information includes: a task execution condition;
before generating a message queue message according to the task information of the task to be processed, the method further comprises the following steps: and confirming that the task to be processed is triggered according to the task execution condition of the task to be processed.
Optionally, the task information includes a task type;
the consumer side processes the task to be processed according to the message queue message, and the processing method comprises the following steps: analyzing the message queue message and determining the service type of the task to be processed; and if the task type of the task to be processed is the same as the application type of the consumption end, acquiring and executing the task to be processed.
Optionally, after configuring task information of the task to be processed, the method further includes: if the task state of the task to be processed is the first task state, adding the task to be processed into a first task table and a second task table; otherwise, adding the task to be processed into a first task table;
acquiring the task to be processed, including: and acquiring the task to be processed from a second task table.
Optionally, the task information includes a task method;
executing the task to be processed, including: and calling a task method of the task to be processed by utilizing reflection so as to execute the task to be processed.
Optionally, the method of the embodiment of the present invention further includes: responding to the task deleting request, and judging the task state of the task to be deleted;
if the task state of the task to be deleted is the first task state, deleting the task to be deleted from the first task table and the second task table; otherwise, deleting the task to be deleted from the first task table.
Optionally, the method of the embodiment of the present invention further includes: in response to the task modification request, performing the following task modification steps:
judging the task state of the task to be modified; if the task state of the task to be modified is the first task state, deleting the task to be modified from the first task table and the second task table; otherwise, deleting the task to be modified from the first task table;
judging the task state of the modified task; if the task state of the modified task is the first task state, adding the modified task into a first task table and a second task table; otherwise, adding the modified task into the first task table.
Optionally, the method of the embodiment of the present invention further includes: responding to a task restarting request, and acquiring a first task table; and adding the tasks to be processed with the first task state in the first task table into the second task table.
According to a second aspect of the embodiments of the present invention, there is provided an apparatus for task scheduling, including:
the task configuration module is used for configuring task information of a task to be processed and generating a message queue message according to the task information of the task to be processed;
and the message subscription module pushes the message queue message to a consuming end subscribed to the message queue service, or responds to a message acquisition request of the consuming end to send the message queue message to the consuming end so that the consuming end processes the task to be processed according to the message queue message.
Optionally, the task information includes task states, and the task states include a first task state and a second task state;
before the task configuration module generates a message queue message according to the task information of the task to be processed, the method further includes: and determining the task state of the task to be processed as a first task state.
Optionally, the task information includes: a task execution condition;
before the task configuration module generates a message queue message according to the task information of the task to be processed, the method further includes: and confirming that the task to be processed is triggered according to the task execution condition of the task to be processed.
Optionally, the task information includes a task type;
the consumer side processes the task to be processed according to the message queue message, and the processing method comprises the following steps: analyzing the message queue message and determining the service type of the task to be processed; and if the task type of the task to be processed is the same as the application type of the consumption end, acquiring and executing the task to be processed.
Optionally, the task configuration module is further configured to: after task information of a task to be processed is configured, if the task state of the task to be processed is a first task state, adding the task to be processed into a first task table and a second task table; otherwise, adding the task to be processed into a first task table;
acquiring the task to be processed, including: and acquiring the task to be processed from a second task table.
Optionally, the task information includes a task method;
executing the task to be processed, including: and calling a task method of the task to be processed by utilizing reflection so as to execute the task to be processed.
Optionally, the task configuration module is further configured to: responding to the task deleting request, and judging the task state of the task to be deleted; if the task state of the task to be deleted is the first task state, deleting the task to be deleted from the first task table and the second task table; otherwise, deleting the task to be deleted from the first task table.
Optionally, the task configuration module is further configured to: in response to the task modification request, performing the following task modification steps:
judging the task state of the task to be modified; if the task state of the task to be modified is the first task state, deleting the task to be modified from the first task table and the second task table; otherwise, deleting the task to be modified from the first task table;
judging the task state of the modified task; if the task state of the modified task is the first task state, adding the modified task into a first task table and a second task table; otherwise, adding the modified task into the first task table.
Optionally, the task configuration module is further configured to: responding to a task restarting request, and acquiring a first task table; and adding the tasks to be processed with the first task state in the first task table into the second task table.
According to a third aspect of the embodiments of the present invention, there is provided a system for task scheduling, including: a task scheduling device and a consuming end subscribing to message queue service;
the task scheduling device configures task information of a task to be processed, generates a message queue message according to the task information of the task to be processed, and pushes the message queue message to the consumption end, or responds to a message acquisition request of the consumption end and sends the message queue message to the consumption end;
and the consumption end receives the message queue message pushed by the task scheduling device, or sends a message acquisition request to the task scheduling device to acquire the message queue message, and processes the task to be processed according to the message queue message.
According to a fourth aspect of the embodiments of the present invention, there is provided an electronic device for task scheduling, 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 are caused to implement the method provided by the first aspect of the embodiments of the present invention.
According to a fifth aspect of embodiments of the present invention, there is provided a computer readable medium, on which a computer program is stored, which when executed by a processor, implements the method provided by the first aspect of embodiments of the present invention.
One embodiment of the above invention has the following advantages or benefits: the task scheduling is realized by issuing uniform subscription service, the maintenance is convenient, the deployment is simple, and the asynchronous decoupling of the task configuration and the task processing can be realized.
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 the main flow of a method of task scheduling of an embodiment of the present invention;
FIG. 2 is a system architecture diagram of task scheduling in an alternative embodiment of the invention;
FIG. 3 is a schematic flow chart of task scheduling in an alternative embodiment of the present invention;
FIG. 4 is a flow diagram of task processing in an alternative embodiment of the invention;
FIG. 5 is a flow diagram illustrating a new task in an alternative embodiment of the present invention;
FIG. 6 is a schematic flow chart of a delete task in an alternative embodiment of the present invention;
FIG. 7 is a schematic flow chart of modification tasks in an alternative embodiment of the invention;
FIG. 8 is a schematic flow chart of a restart task in an alternative embodiment of the present invention;
FIG. 9 is a schematic diagram of the main modules of an apparatus for task scheduling according to an embodiment of the present invention;
FIG. 10 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 11 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present 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.
According to an aspect of an embodiment of the present invention, a method for task scheduling is provided.
Fig. 1 is a schematic diagram of a main flow of a task scheduling method according to an embodiment of the present invention, and as shown in fig. 1, the task scheduling method includes: step S101, step S102, and step S103.
And S101, configuring task information of the task to be processed.
The task information refers to information related to the task, such as task type, task state, execution mode of the task, execution condition, and the like. Illustratively, the task information may include any one or more of the following attributes:
jobName: task aliases, such as: worker1, worker 2.
serviceName: task methods are often expressed in the form of "class name. method name", e.g., serviceclient. method ().
cronexsion: cron (planning task) executes the expression.
jobDesc: and (5) describing the task.
Type: the type of service, for example: the service type of the order system is 1, and the service type of the quotation system is 2.
Status: task states, for example: 1 represents the open leg and 2 the closed state.
And step S102, generating a message queue message according to the task information of the task to be processed.
The message queue message indicates that the current task has been generated for pushing to the consuming side or for pulling by the consuming side. And the consumption end executes the corresponding task to be processed by analyzing the message queue message. And the message queue is adopted to store the message queue message corresponding to the task to be processed, so that asynchronous decoupling of task configuration and processing can be realized.
After the task information is configured in step S101, the task to be processed may be saved to the database. Optionally, the task information includes a task state, the task state including a first task state and a second task state. Before generating a message queue message according to the task information of the task to be processed, the method further comprises the following steps: and determining the task state of the task to be processed as a first task state. The specific contents of the first task state and the second task state can be selectively set according to actual conditions, and the task state of each task to be processed can be dynamically modified in the actual application process.
Illustratively, the first task state is an on state and the second task state is an off state. And triggering the task in the open state after the task reaches the triggering condition, generating a message queue message according to the task information of the task to be processed, and pushing the generated message queue message to a message queue. The messages in the message queue can be pushed to the consumption end or pulled by the consumption end in an asynchronous mode.
The information corresponding to the task to be processed in the first task state is published for consumption by a consumption end subscribing the information queue service, and diversified management of the task to be processed in different task states can be realized.
Optionally, the task information includes: and executing the task. Before generating a message queue message according to the task information of the task to be processed, the method further comprises the following steps: and confirming that the task to be processed is triggered according to the task execution condition of the task to be processed. The task execution condition is used for expressing a trigger condition of the task to be processed.
Illustratively, the task execution condition of the to-be-processed task a is to start execution at 9 am every day. And generating a message queue message according to the task information of the task A to be processed at 9 am every day and issuing the message queue message. And generating and publishing the corresponding message after the to-be-processed task is triggered, so that the to-be-processed task corresponding to each message in the published message queue can be processed preferentially, and the timeliness of processing each to-be-processed task can be improved.
Step S103, pushing the message queue message to a consuming end subscribing to a message queue service, or responding to a message acquisition request of the consuming end to send the message queue message to the consuming end, so that the consuming end processes a task to be processed according to the message queue message. The task scheduling is realized by issuing uniform subscription service, the maintenance is convenient, the deployment is simple, and the asynchronous decoupling of the task configuration and the task processing can be realized.
Optionally, the task information comprises a task type. The consumer side processes the task to be processed according to the message queue message, and the processing method comprises the following steps: analyzing the message queue message and determining the service type of the task to be processed; and if the task type of the task to be processed is the same as the application type of the consumption end, acquiring and executing the task to be processed.
The division mode of the task type can be selectively set according to the actual situation. Taking the e-commerce field as an example, the task types can be divided into an order type task, a quotation type task, a payment type task and the like according to the type of the consumption end processing the task to be processed. Taking the bank field as an example, the task type can be divided into a personal business type task, a company business type task and the like according to the applicant type for processing the task to be processed.
Each consumption end only processes the tasks to be processed of the corresponding type, so that on one hand, the time efficiency of task processing can be improved, and on the other hand, the same task to be processed can be prevented from being repeatedly executed.
In an optional embodiment, after configuring the task information of the task to be processed, the method may further include: if the task state of the task to be processed is the first task state, adding the task to be processed into a first task table and a second task table; otherwise, adding the task to be processed into a first task table. Acquiring the task to be processed, including: and acquiring the task to be processed from a second task table.
Exemplarily, the task state of the to-be-processed task B is a closed state, and the to-be-processed task B is added to the first task table after the task information of the to-be-processed task B is configured. And if the task state of the task C to be processed is the opening state, adding the task C to be processed into the first task table and the second task table after configuring the task information of the task C to be processed. In this example, the first task table stores all the tasks to be processed, and the second task table stores the tasks to be processed in the open state.
The tasks to be processed in different task states are managed through the first task table and the second task table, so that the tasks to be processed in different task states can be maintained and deployed respectively, and diversified management of the tasks to be processed in different task states is achieved.
Optionally, the task information includes a task method. Executing the task to be processed, including: and calling a task method of the task to be processed by utilizing reflection so as to execute the task to be processed. The task method refers to a method of implementing execution of a task to be processed by executing itself. The task method for configuring the tasks to be processed in the task information facilitates accurate and rapid determination of the execution mode of the tasks to be processed, and improves the accuracy of task execution.
In the embodiment of the invention, the first task table and the second task table are used for storing the tasks to be processed in different task states. In the actual application process, operations such as adding, deleting, modifying, checking and the like can be performed on the first task table and the second task table so as to improve the flexibility of task scheduling.
In some embodiments, in response to a task addition request, a task state of a task to be added is determined. If the task state of the task to be newly added is the first task state, adding the task to be newly added into the first task table and the second task table; otherwise, the task to be newly added is entered into the first task table.
Fig. 5 is a flowchart illustrating a new task in an alternative embodiment of the present invention. As shown in fig. 5, the flow of the new task includes: step S501, judging the task state of the newly added task, wherein the task state is a state to be set; if the task state of the newly added task is the starting state, jumping to the step S502; otherwise, the process jumps to step S506. Step S502, an org.quartz.JobD etail object is constructed. And S503, constructing an org.quartz.CronTrigger object. Step S504, execute the scheduler job (jobdetail.trigger) method. Step S505, start scheduling. Step S506, storing the data to mysql (a relational database management system) database. In this example, the org.quartz.j.obdetail object, the org.quartz.cron trigger object, the scheduler.scheduler job (job delay.trigger) method, and the scheduler.start [ ] mentioned in steps S502 to S505 are all configuration information in the quartz (an open source item) frame, and the purpose of steps S502 to S504 is to start calling the scheduler.st art [ ], and the purpose of starting calling the scheduler.start [ ] is to set the task state of the newly added task to the on state, so that the newly added task can be executed at regular time.
In still other embodiments, in response to a task delete request, a task state of a task to be deleted is determined. If the task state of the task to be deleted is the first task state, deleting the task to be deleted from the first task table and the second task table; otherwise, the task to be deleted is deleted from the first task table.
Fig. 6 is a schematic flowchart of a task deletion process in an alternative embodiment of the present invention, and as shown in fig. 6, the task deletion process includes: step S601, determining a task state of the task to be deleted, if the task state of the task to be deleted is an open state, jumping to step S602, otherwise, jumping to step S607. Step S602, acquiring JobDetail (task description) according to the task name. Step S603 determines whether the JobDetail is true, that is, determines whether the JobDetail is empty, and if the process is finished, otherwise, the process goes to step S604. Step S604, stopping the trigger according to the task name, that is, stopping the trigger corresponding to the task to be deleted according to the task name of the task to be deleted, so as to prevent the task to be deleted from being triggered. And step S605, removing the trigger according to the task name, namely removing the trigger corresponding to the task to be deleted according to the task name of the task to be deleted. And step S606, deleting the trigger according to the task name, namely deleting the trigger corresponding to the task to be deleted according to the task name of the task to be deleted. The task to be deleted is deleted from the second task table through the operations of step S604 to step S606. And step S607, according to the primary key id, the corresponding data in the database is physically deleted, namely the task to be deleted is deleted from the first task table.
In other embodiments, in response to a task modification request, the following task modification steps are performed: (1) judging the task state of the task to be modified; if the task state of the task to be modified is the first task state, deleting the task to be modified from the first task table and the second task table; otherwise, deleting the task to be modified from the first task table; (2) judging the task state of the modified task; if the task state of the modified task is the first task state, adding the modified task into the first task table and the second task table; otherwise, adding the modified task into the first task table. Steps (1) and (2) may be performed simultaneously or sequentially. In addition, when the steps (1) and (2) are sequentially executed, the execution sequence between the steps can be arbitrarily adjusted.
FIG. 7 is a flow chart illustrating modification tasks in an alternative embodiment of the present invention. As shown in fig. 7, the flow of modification tasks includes the step S701 of executing the deletion logic and the step S702 of executing the addition logic. The deleting logic refers to the flow shown in fig. 6, and the adding logic refers to the flow shown in fig. 5, which is not described herein again.
In still other embodiments, in response to a task restart request, a first task table is obtained; and adding the tasks to be processed with the first task state in the first task table into the second task table.
Fig. 8 is a flowchart of a restart task in an alternative embodiment of the invention. In this example, the database is used to store the first task table, and the scheduler container is used to store the task to be processed in the open state. As shown in fig. 8, when the restart task is, for example, to restart a module for configuring a task to be processed, step S801 is executed to acquire all on-state timing tasks from a database, and step S802 dynamically adds the acquired tasks to a scheduler container.
Fig. 2 is a schematic diagram of a system architecture for task scheduling in an alternative embodiment of the present invention. In this example, the task management system publishes the message queue service to Kafka (an open source streaming platform), and the consumer subscribes to the message queue from Kafka. And the task management system executes the steps of configuring the task information of the task to be processed and generating a message queue message according to the task information of the task to be processed. The task management system pushes each task to be processed to the Kafka in a message queue mode, and the Kafka actively pushes the message in the message queue to the consumption end. The consuming side can also pull message queue messages from Kafka periodically. And the consumption end judges the task type of the task to be processed by analyzing the message queue message and selectively executes each task to be processed according to the task type of the task to be processed.
Fig. 3 is a flow chart illustrating task scheduling in an alternative embodiment of the present invention. In this example, the task scheduling platform determines whether the task to be processed is triggered according to the task execution condition of the task to be processed. When the pending task is triggered, a custom job is first executed to generate a message queue message, which is then sent to Kafka. The application server side, namely the consumption side, is in charge of subscribing the message, analyzes the message after pulling the message, judges whether the task to be processed needs to be processed according to the task type in the message body, processes the message if the task needs to be processed, does not need to skip the message, and continues to pull and analyze other messages.
In general, when the application type of the application server corresponds to the task type of the task to be processed, the task to be processed is processed.
Taking an application server with an application type of 1 as an example, fig. 4 shows a flowchart of task processing. As shown in fig. 4, in step S401, the parsing message body determines the task type of the task to be processed. It is determined in step S402 whether the task type of the task to be processed is equal to 1. If yes, go to step S403, otherwise, the process ends. In step S403, a serverName (i.e., a task method, usually expressed in the form of a class name or a method name, such as serviceclient. hierarchical method ()) in the message body is obtained, and the attribute is split (i.e., each task method is obtained separately). In step S404, the object is obtained from the spring container (spring is an open source framework, in this example, the spring is used to store the task to be processed in the first task state, and in this step, the task to be processed corresponding to the message is obtained from the spring), then the method is called by reflection to execute the task to be processed, and then the process is ended.
The invention relates to a method for realizing unified management of task scheduling based on a universal message queue service calling mode, which realizes unified management of tasks based on a universal message queue through unified configuration of task information and unified publishing and subscribing message queue service, can realize asynchronous decoupling of task configuration and processing, and has the advantages of simple configuration and deployment, unified maintenance and convenient use.
According to a second aspect of the embodiments of the present invention, there is provided an apparatus for implementing the above method.
Fig. 9 is a schematic diagram of main modules of an apparatus for task scheduling according to an embodiment of the present invention, and as shown in fig. 9, the apparatus 900 for task scheduling includes: a task configuration module 901 and a message subscription module 902; wherein the content of the first and second substances,
the task configuration module 901 is configured to configure task information of a task to be processed and generate a message queue message according to the task information of the task to be processed;
the message subscription module 902 pushes the message queue message to a consuming side subscribing to a message queue service, or sends the message queue message to the consuming side in response to a message obtaining request of the consuming side, so that the consuming side processes a task to be processed according to the message queue message.
Optionally, the task information includes task states, and the task states include a first task state and a second task state;
before the task configuration module generates a message queue message according to the task information of the task to be processed, the method further includes: and determining the task state of the task to be processed as a first task state.
Optionally, the task information includes: a task execution condition;
before the task configuration module generates a message queue message according to the task information of the task to be processed, the method further includes: and confirming that the task to be processed is triggered according to the task execution condition of the task to be processed.
Optionally, the task information includes a task type;
the consumer side processes the task to be processed according to the message queue message, and the processing method comprises the following steps: analyzing the message queue message and determining the service type of the task to be processed; and if the task type of the task to be processed is the same as the application type of the consumption end, acquiring and executing the task to be processed.
Optionally, the task configuration module is further configured to: after task information of a task to be processed is configured, if the task state of the task to be processed is a first task state, adding the task to be processed into a first task table and a second task table; otherwise, adding the task to be processed into a first task table;
acquiring the task to be processed, including: and acquiring the task to be processed from a second task table.
Optionally, the task information includes a task method;
executing the task to be processed, including: and calling a task method of the task to be processed by utilizing reflection so as to execute the task to be processed.
Optionally, the task configuration module is further configured to: responding to the task deleting request, and judging the task state of the task to be deleted; if the task state of the task to be deleted is the first task state, deleting the task to be deleted from the first task table and the second task table; otherwise, deleting the task to be deleted from the first task table.
Optionally, the task configuration module is further configured to: in response to the task modification request, performing the following task modification steps:
judging the task state of the task to be modified; if the task state of the task to be modified is the first task state, deleting the task to be modified from the first task table and the second task table; otherwise, deleting the task to be modified from the first task table;
judging the task state of the modified task; if the task state of the modified task is the first task state, adding the modified task into a first task table and a second task table; otherwise, adding the modified task into the first task table.
Optionally, the task configuration module is further configured to: responding to a task restarting request, and acquiring a first task table; and adding the tasks to be processed with the first task state in the first task table into the second task table.
According to a third aspect of the embodiments of the present invention, there is provided a system for task scheduling, including: a task scheduling device and a consuming end subscribing to message queue service;
the task scheduling device configures task information of a task to be processed, generates a message queue message according to the task information of the task to be processed, and pushes the message queue message to the consumption end, or responds to a message acquisition request of the consumption end and sends the message queue message to the consumption end;
and the consumption end receives the message queue message pushed by the task scheduling device, or sends a message acquisition request to the task scheduling device to acquire the message queue message, and processes the task to be processed according to the message queue message.
According to a fourth aspect of the embodiments of the present invention, there is provided an electronic device for task scheduling, 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 are caused to implement the method provided by the first aspect of the embodiments of the present invention.
According to a fifth aspect of embodiments of the present invention, there is provided a computer readable medium, on which a computer program is stored, which when executed by a processor, implements the method provided by the first aspect of embodiments of the present invention.
Fig. 10 shows an exemplary system architecture 1000 of a method or apparatus for task scheduling to which embodiments of the present invention may be applied.
As shown in fig. 10, the system architecture 1000 may include terminal devices 1001, 1002, 1003, a network 1004, and a server 1005. The network 1004 is used to provide a medium for communication links between the terminal devices 1001, 1002, 1003 and the server 1005. Network 1004 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 1001, 1002, 1003 to interact with a server 1005 via a network 1004 to receive or transmit messages or the like. The terminal devices 1001, 1002, 1003 may have installed thereon various messenger client applications such as shopping applications, web browser applications, search applications, instant messenger, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 1001, 1002, 1003 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 1005 may be a server that provides various services, such as a backend management server (for example only) that supports shopping websites browsed by users using the terminal devices 1001, 1002, 1003. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for task scheduling provided by the embodiment of the present invention is generally executed by the server 1005, and accordingly, the device for task scheduling is generally disposed in the server 1005.
It should be understood that the number of terminal devices, networks, and servers in fig. 10 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 11, shown is a block diagram of a computer system 1100 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 11 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. 11, the computer system 1100 includes a Central Processing Unit (CPU)1101, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)1102 or a program loaded from a storage section 1108 into a Random Access Memory (RAM) 1103. In the RAM 1103, various programs and data necessary for the operation of the system 1100 are also stored. The CPU 1101, ROM 1102, and RAM 1103 are connected to each other by a bus 1104. An input/output (I/O) interface 1105 is also connected to bus 1104.
The following components are connected to the I/O interface 1105: an input portion 1106 including a keyboard, mouse, and the like; an output portion 1107 including a signal output unit such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage section 1108 including a hard disk and the like; and a communication section 1109 including a network interface card such as a LAN card, a modem, or the like. The communication section 1109 performs communication processing via a network such as the internet. A driver 1110 is also connected to the I/O interface 1105 as necessary. A removable medium 1111 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1110 as necessary, so that a computer program read out therefrom is mounted into the storage section 1108 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 portion 1109 and/or installed from the removable medium 1111. The above-described functions defined in the system of the present invention are executed when the computer program is executed by a Central Processing Unit (CPU) 1101.
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: the processor comprises a task configuration module, a message queue module and a message queue module, wherein the task configuration module is used for configuring task information of a task to be processed and generating message queue messages according to the task information of the task to be processed; and the message subscription module pushes the message queue message to a consuming end subscribed to the message queue service, or responds to a message acquisition request of the consuming end to send the message queue message to the consuming end so that the consuming end processes the task to be processed according to the message queue message. The names of these modules do not constitute a limitation to the module itself in some cases, for example, the message subscription module may also be described as a "module configuring task information of a task to be processed".
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: configuring task information of a task to be processed, and generating a message queue message according to the task information of the task to be processed; and pushing the message queue message to a consuming end subscribing the message queue service, or responding to a message acquisition request of the consuming end to send the message queue message to the consuming end so that the consuming end processes the task to be processed according to the message queue message.
According to the technical scheme of the embodiment of the invention, task scheduling is realized by releasing uniform subscription service, the maintenance is convenient, the deployment is simple, and asynchronous decoupling of task configuration and processing can be realized.
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 (13)

1. A method of task scheduling, comprising:
configuring task information of a task to be processed;
generating a message queue message according to the task information of the task to be processed;
and pushing the message queue message to a consuming end subscribing the message queue service, or responding to a message acquisition request of the consuming end to send the message queue message to the consuming end so that the consuming end processes the task to be processed according to the message queue message.
2. The method of claim 1, wherein the task information includes task states, the task states including a first task state and a second task state;
before generating a message queue message according to the task information of the task to be processed, the method further comprises the following steps: and determining the task state of the task to be processed as a first task state.
3. The method of claim 2, wherein the task information comprises: a task execution condition;
before generating a message queue message according to the task information of the task to be processed, the method further comprises the following steps: and confirming that the task to be processed is triggered according to the task execution condition of the task to be processed.
4. The method of claim 2, wherein the task information includes a task type;
the consumer side processes the task to be processed according to the message queue message, and the processing method comprises the following steps: analyzing the message queue message and determining the service type of the task to be processed; and if the task type of the task to be processed is the same as the application type of the consumption end, acquiring and executing the task to be processed.
5. The method of claim 4, wherein after configuring task information for the pending task, further comprising: if the task state of the task to be processed is the first task state, adding the task to be processed into a first task table and a second task table; otherwise, adding the task to be processed into a first task table;
acquiring the task to be processed, including: and acquiring the task to be processed from a second task table.
6. The method of claim 4, wherein the task information includes a task method;
executing the task to be processed, including: and calling a task method of the task to be processed by utilizing reflection so as to execute the task to be processed.
7. The method of claim 5, further comprising:
responding to the task deleting request, and judging the task state of the task to be deleted;
if the task state of the task to be deleted is the first task state, deleting the task to be deleted from the first task table and the second task table; otherwise, deleting the task to be deleted from the first task table.
8. The method of claim 5, further comprising:
in response to the task modification request, performing the following task modification steps:
judging the task state of the task to be modified; if the task state of the task to be modified is the first task state, deleting the task to be modified from the first task table and the second task table; otherwise, deleting the task to be modified from the first task table;
judging the task state of the modified task; if the task state of the modified task is the first task state, adding the modified task into a first task table and a second task table; otherwise, adding the modified task into the first task table.
9. The method of claim 5, further comprising:
responding to a task restarting request, and acquiring a first task table; and adding the tasks to be processed with the first task state in the first task table into the second task table.
10. An apparatus for task scheduling, comprising:
the task configuration module is used for configuring task information of a task to be processed and generating a message queue message according to the task information of the task to be processed;
and the message subscription module pushes the message queue message to a consuming end subscribed to the message queue service, or responds to a message acquisition request of the consuming end to send the message queue message to the consuming end so that the consuming end processes the task to be processed according to the message queue message.
11. A system for task scheduling, comprising: a task scheduling device and a consuming end subscribing to message queue service; wherein the content of the first and second substances,
the task scheduling device configures task information of a task to be processed, generates a message queue message according to the task information of the task to be processed, and pushes the message queue message to the consumption end, or responds to a message acquisition request of the consumption end and sends the message queue message to the consumption end;
and the consumption end receives the message queue message pushed by the task scheduling device, or sends a message acquisition request to the task scheduling device to acquire the message queue message, and processes the task to be processed according to the message queue message.
12. An electronic device for task scheduling, 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-9.
13. 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-9.
CN202010412494.XA 2020-05-15 2020-05-15 Task scheduling method, device and system Pending CN113672357A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010412494.XA CN113672357A (en) 2020-05-15 2020-05-15 Task scheduling method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010412494.XA CN113672357A (en) 2020-05-15 2020-05-15 Task scheduling method, device and system

Publications (1)

Publication Number Publication Date
CN113672357A true CN113672357A (en) 2021-11-19

Family

ID=78537623

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010412494.XA Pending CN113672357A (en) 2020-05-15 2020-05-15 Task scheduling method, device and system

Country Status (1)

Country Link
CN (1) CN113672357A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114979100A (en) * 2022-04-15 2022-08-30 深信服科技股份有限公司 Cloud resource checking method and related device
CN116319650A (en) * 2023-05-22 2023-06-23 三一海洋重工有限公司 Port equipment data distribution method, device and system and container crane
CN116501376A (en) * 2023-06-26 2023-07-28 和创(北京)科技股份有限公司 Decoupling method, system and device based on configuration instant trigger task

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114979100A (en) * 2022-04-15 2022-08-30 深信服科技股份有限公司 Cloud resource checking method and related device
CN114979100B (en) * 2022-04-15 2024-02-23 深信服科技股份有限公司 Cloud resource inspection method and related device
CN116319650A (en) * 2023-05-22 2023-06-23 三一海洋重工有限公司 Port equipment data distribution method, device and system and container crane
CN116319650B (en) * 2023-05-22 2024-01-30 三一海洋重工有限公司 Port equipment data distribution method, device and system and container crane
CN116501376A (en) * 2023-06-26 2023-07-28 和创(北京)科技股份有限公司 Decoupling method, system and device based on configuration instant trigger task
CN116501376B (en) * 2023-06-26 2023-09-12 和创(北京)科技股份有限公司 Decoupling method, system and device based on configuration instant trigger task

Similar Documents

Publication Publication Date Title
CN110310034B (en) Service arrangement and business flow processing method and device applied to SaaS
CN113672357A (en) Task scheduling method, device and system
CN110795147A (en) Interface protocol file management method and device
CN111917687A (en) Method and device for circularly pushing reminding message
CN111478781B (en) Message broadcasting method and device
CN112653614A (en) Request processing method and device based on message middleware
CN112398669B (en) Hadoop deployment method and device
CN113760488A (en) Method, device, equipment and computer readable medium for scheduling task
CN110389976B (en) Multi-interface data scheduling method and device
CN112084042A (en) Message processing method and device
CN110807535A (en) Construction method and construction device of unified reservation platform and unified reservation platform system
CN113672671B (en) Method and device for realizing data processing
CN111831503B (en) Monitoring method based on monitoring agent and monitoring agent device
CN108833147B (en) Configuration information updating method and device
CN111786801B (en) Method and device for charging based on data flow
CN113779122B (en) Method and device for exporting data
CN113760487B (en) Service processing method and device
CN112688982B (en) User request processing method and device
CN110909269B (en) Log reporting method and device
CN114490050A (en) Data synchronization method and device
CN113743630A (en) Method and device for executing intelligent call reservation
CN113760482A (en) Task processing method, device and system
CN112182003A (en) Data synchronization method and device
CN113572704A (en) Information processing method, production end, consumption end and server
CN112784187A (en) Page display 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