Task scheduling method and device, electronic equipment and storage medium
By designing a task scheduling method that uses the cache database queue, it solves the problem of only a single task that can only perform a single task at the same time at the same time, realize the multi -tasking concurrent execution and rapid overtime response, which improves the task execution efficiency and system stability.
Patent Information
- Application Number
- CN202411463180.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-18
AI Technical Summary
In the prior art, the acquisition terminal can only execute a single task at the same time, resulting in the possibility of backlog of task queues and repeated concurrent execution. In addition, the timeout mechanism cannot be effectively handled during the task execution.
By designing a task scheduling method, the notification queue, waiting queue and working queue are used to achieve the efficient scheduling and execution of the task. Specific steps include analyzing the task data to be processed, obtaining the identification and task priority of the collection terminal. Based on the number of tasks in the query queue of the identification query work, if the threshold is not exceeded, it will get the highest priority task data from the waiting queue, and write it to it. Work queue.
The collection terminal can perform multiple tasks at the same time, improve the execution efficiency of the terminal side, reduce the possibility of task queue voltage and repeated concurrency execution, and quickly respond and handle tasks through the timeout mechanism.
Smart Images

Figure CN119376884A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power collection, and in particular to a task scheduling method, device, electronic equipment and storage medium. Background Art
[0002] With the development and application of technologies such as big data, artificial intelligence, and cloud computing, the new generation of electricity information collection systems has core capabilities such as security authentication, full data collection, dispatch control, massive storage, real-time analysis, and global monitoring. In the face of the access and remote dispatch business needs of massive data collection terminal devices, higher requirements are placed on terminal dispatch management such as high performance, high availability, security, and stability.
[0003] The acquisition terminal of the related technical solution can only execute a single task at the same time, and other tasks need to queue up or even refuse to queue up on the terminal side. When there are a large number of service nodes, there is a possibility of repeated concurrent execution of tasks. Summary of the invention
[0004] The embodiments of the present invention aim to solve at least one of the technical problems in the related art to a certain extent. To this end, one object of the present invention is to provide a task scheduling method, device, electronic device and storage medium that can improve execution efficiency and support timeout fast response.
[0005] The embodiment of the present specification provides a task scheduling method, which is applied to a task scheduling system. The task scheduling system can communicate data with a cache database, and the cache database includes at least a notification queue, a waiting queue, and a working queue. The task scheduling method includes: when monitoring the pending task data in the message middleware component, parsing and processing the pending task data to obtain the identification of the collection terminal for task processing, the task identification, and the task priority, wherein the pending task data in the message middleware component is pushed by the business service system; sending the identification of the collection terminal to the notification queue, and sending the pending task data and the task priority to the waiting queue; when monitoring the notification queue In the case of the identification of the collection terminal in the queue, the cache database is notified to execute the sending script, wherein, by executing the sending script, it is possible to achieve: based on the identification of the collection terminal, query the number of tasks currently being executed by the collection terminal in the working queue, and when the number of tasks does not exceed the number threshold, obtain the target task data with the highest priority corresponding to the collection terminal from the waiting queue, and write the task identification corresponding to the target task data into the working queue; after executing the sending script, process the target task data corresponding to the task identification in the working queue to obtain the sending protocol message data, and send the sending protocol message data to the collection terminal, so that the collection terminal performs task processing based on the sending protocol message data to obtain the task execution result.
[0006] Exemplarily, the cache database also includes a timeout queue; by executing the issued script, it can also be achieved: after obtaining the target task data with the highest priority corresponding to the collection terminal from the waiting queue, parsing the target task data to obtain the timeout time interval, and writing the timeout time interval, the collection terminal identifier and the task identifier into the timeout queue.
[0007] Exemplarily, after executing the sending script, the target task data corresponding to the task identifier in the work queue is processed to obtain the sending protocol message data, including: after executing the sending script, if the target task data returned from the cache database is received, a frame number that can be parsed by the acquisition terminal is generated based on the identifier of the acquisition terminal; the target task data and the frame number are converted into a protocol to obtain the sending protocol message data.
[0008] Exemplarily, the task scheduling method also includes: after notifying the cache database to execute the sending script, storing the target task data as the sending task data in the sending data cache area in the cache database; after receiving the task execution result returned by the acquisition terminal, parsing the frame number from the task execution result; obtaining the sending task data corresponding to the frame number from the sending data cache area; parsing the sending task data corresponding to the frame number in the sending data cache area to obtain the uplink normal message data and the task identifier; pushing the uplink normal message data, the task identifier and the task execution result to the business service system through the message middleware component.
[0009] Exemplarily, the task scheduling method also includes: after obtaining the downlink task data corresponding to the frame sequence number from the downlink data cache area, notifying the cache database to execute the response script, wherein, by executing the response script, it is possible to achieve: deleting the timeout time interval corresponding to the task identifier obtained by parsing, the identifier of the collection terminal and the task identifier, and deleting the downlink task data corresponding to the task identifier obtained by parsing from the downlink data cache area; after pushing the uplink normal message data, task identifier and task execution result to the business service system through the message middleware component, sending an instruction to process the next task to the notification queue.
[0010] Exemplarily, the task scheduling method also includes: notifying the cache database to execute a timeout script, wherein, by executing the timeout script, it is possible to achieve: determining the timed-out target task data based on the timeout time interval in the timeout queue; obtaining the identifier of the collection terminal and the task identifier corresponding to the timed-out target task data, and deleting the timed-out target task data from the timeout queue; deleting the task identifier in the work queue based on the task identifier corresponding to the timed-out target task data; obtaining an uplink timeout message based on the identifier of the collection terminal, the task identifier and the timeout information corresponding to the timed-out target task data; pushing the uplink timeout message to the business service system through the message middleware component, and sending an instruction to process the next task to the notification queue.
[0011] Exemplarily, the task scheduling system includes multiple service nodes, and the multiple service nodes can perform task scheduling concurrently; each acquisition terminal can execute multiple tasks at the same time.
[0012] Exemplarily, sending the protocol message data to the collection terminal includes: the task scheduling system sends the protocol message data to the front-end gateway, so that the front-end gateway sends the protocol message data to the collection terminal; receiving the task execution result returned by the collection terminal includes: the task scheduling system receives the task execution result sent from the front-end gateway, wherein the task execution result of the front-end gateway comes from the collection terminal.
[0013] The embodiment of the present specification provides a task scheduling device, which includes: a monitoring and parsing module, which is used to parse and process the pending task data in the message middleware component when monitoring the pending task data in the message middleware component, and obtain the identification of the collection terminal used for task processing, the task identification and the task priority, wherein the pending task data in the message middleware component is pushed by the business service system; a sending module, which is used to send the identification of the collection terminal to the notification queue, and send the pending task data and the task priority to the waiting queue; a notification execution module, which is used to notify the cache database to execute the sending when monitoring the identification of the collection terminal in the notification queue A script, wherein the execution of the issued script can achieve: based on the identification of the collection terminal, query the number of tasks currently being executed by the collection terminal in the work queue, and when the number of tasks does not exceed the number threshold, obtain the target task data with the highest priority corresponding to the collection terminal from the waiting queue, and write the task identification corresponding to the target task data into the work queue; a message acquisition and sending module, which is used to process the target task data corresponding to the task identification in the work queue after executing the issued script to obtain the issued protocol message data, and send the issued protocol message data to the collection terminal, so that the collection terminal can process the task based on the issued protocol message data to obtain the task execution result.
[0014] An embodiment of the present specification provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method of any of the above embodiments are implemented.
[0015] The embodiments of this specification provide a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method of any of the above embodiments are implemented.
[0016] In the above-mentioned implementation mode of the specification, the task scheduling method includes: when monitoring the pending task data in the message middleware component, parsing and processing the pending task data to obtain the identification of the collection terminal used for task processing, the task identification and the task priority, wherein the pending task data in the message middleware component is pushed by the business service system; sending the identification of the collection terminal to the notification queue, and sending the pending task data and the task priority to the waiting queue; when monitoring the identification of the collection terminal in the notification queue, notifying the cache database to execute the sending script, wherein, by executing the sending script, it is possible to achieve: based on the identification of the collection terminal, querying the number of tasks currently being executed by the collection terminal in the working queue, when the number of tasks does not exceed the number threshold, obtaining the target task data with the highest priority corresponding to the collection terminal from the waiting queue, and writing the task identification corresponding to the target task data into the working queue; after executing the sending script, processing the target task data corresponding to the task identification in the working queue to obtain the sending protocol message data, and sending the sending protocol message data to the collection terminal, so that the collection terminal performs task processing based on the sending protocol message data to obtain the task execution result. The above task scheduling method optimizes the task scheduling of the server, so that the collection terminal can execute multiple different tasks at the same time, thereby improving the execution efficiency on the terminal side.
[0017] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A schematic diagram of the redis structure of the cache database provided for the implementation of this specification;
[0019] Figure 2 A flowchart of a task scheduling method provided for an embodiment of this specification;
[0020] Figure 3 The overall flow chart of task distribution provided for the implementation mode of this specification;
[0021] Figure 4 A task dispatching service processing flow chart provided for the implementation mode of this specification;
[0022] Figure 5 The overall flow chart of normal response to tasks provided for the implementation mode of this specification;
[0023] Figure 6 A flowchart of the task normal response scheduling service processing provided for the implementation mode of this specification;
[0024] Figure 7 The overall flow chart of task timeout response provided for the implementation mode of this specification;
[0025] Figure 8 A task timeout response scheduling service processing flow chart provided for the implementation mode of this specification;
[0026] Fig. 9 A schematic diagram of a task scheduling device provided in an implementation manner of this specification. DETAILED DESCRIPTION
[0027] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0028] With the development and application of technologies such as big data, artificial intelligence, and cloud computing, the new generation of electricity information collection systems has core capabilities such as security authentication, full data collection, dispatch control, massive storage, real-time analysis, and global monitoring. In the face of the access and remote dispatch business needs of massive data collection terminal devices, higher requirements are placed on terminal dispatch management such as high performance, high availability, security, and stability.
[0029] According to the related technical solution, the collection terminal can only execute a single task at the same time, and other tasks need to queue up or even refuse to queue up on the collection terminal side; if the collection terminal is stuck, disconnected, or responds abnormally during the execution of a task, its timeout mechanism cannot ensure that the task in the device sequence can get a chance to be executed; when there are a large number of service nodes in the task scheduling system (the task scheduling system includes multiple service nodes, and the service nodes can be servers), the same task may be repeatedly executed concurrently by multiple service nodes; when the collection terminal responds to a large single message, it will respond in frames. If the terminal receives a new task at this time, it will cause the ongoing frame interruption and incomplete data collection; issuing a large number of instructions at the same time will cause the terminal to refuse to respond.
[0030] To this end, the implementation method of this specification provides a task scheduling method, which conducts remote task management to the acquisition terminal through the cloud platform system (task scheduling system), ensures the stability of the task by expanding the service nodes when facing a large number of tasks, reduces task blocking by limiting the number of concurrent instructions of a single device, and designs a timeout mechanism to reduce the overall running time of the task, thereby improving the efficiency of task execution.
[0031] The method for task scheduling of a power collection terminal proposed in the present invention includes a task issuing process and a task response process, wherein the task response process is divided into two categories: normal task response and task timeout response. The task scheduling method is applied to a task scheduling system, and the task scheduling system can communicate data with a cache database, and the cache database at least includes a notification queue, a waiting queue, and a work queue. Among them, the task scheduling system includes multiple service nodes, and the multiple service nodes can perform task scheduling concurrently; each collection terminal can execute multiple tasks at the same time.
[0032] Exemplarily, the cache database used by the task scheduling method is a redis database, and the structure of the database is as follows: Figure 1 As shown, it includes notification queue, waiting queue, working queue, timeout queue, frame sequence number cache and sent data cache. Among them, the attribute value of the notification queue is the device ID (the identification of the acquisition terminal), the attribute value of the waiting queue is the task priority and the sent task information JSON data (pending task data), the attribute value of the working queue is the task ID (task identification), the attribute value of the timeout queue is the timeout task timestamp (seconds) and the device ID#task ID (# represents a connector, which is used to separate the device ID and the task ID), the frame sequence number cache attribute value is a self-incrementing integer, and the sent data cache attribute value is the sent task JSON data. The task scheduling system provides multiple service nodes to execute task scheduling concurrently.
[0033] In the above embodiment, the cache database includes multiple queue forms, each queue is responsible for completing a specific function with clear division of labor; the task scheduling system has multiple service nodes, which can execute task scheduling concurrently to improve the task execution efficiency when there are a large number of tasks.
[0034] Figure 2 A flowchart of a task scheduling method provided in an embodiment of this specification.
[0035] like Figure 2 As shown, the task scheduling method 200 of the example of this specification includes steps S210-S240.
[0036] Step S210, when monitoring the pending task data in the message middleware component, parse and process the pending task data to obtain the identification of the collection terminal used for task processing, the task identification and the task priority. The pending task data in the message middleware component is pushed by the business service system.
[0037] Step S220: sending the identifier of the collection terminal to the notification queue, and sending the task data to be processed and the task priority to the waiting queue.
[0038] Step S230, when the identifier of the collection terminal in the notification queue is monitored, the cache database is notified to execute the sent script. By executing the sent script, it is possible to: query the number of tasks currently being executed by the collection terminal in the working queue based on the identifier of the collection terminal. When the number of tasks does not exceed the number threshold, obtain the highest priority target task data corresponding to the collection terminal from the waiting queue, and write the task identifier corresponding to the target task data into the working queue.
[0039] Step S240, after executing the sending script, the target task data corresponding to the task identifier in the work queue is processed to obtain the sending protocol message data, and the sending protocol message data is sent to the collection terminal, so that the collection terminal performs task processing based on the sending protocol message data to obtain the task execution result.
[0040] Figure 3 The overall flow chart of task distribution provided for the implementation mode of this specification is as follows: Figure 4 This is a task dispatching service processing flow chart provided in the implementation mode of this specification.
[0041] like Figure 3 , Figure 4 As shown, the task dispatching scheduling service processing flow includes, when monitoring the pending task data in the message middleware component, parsing and processing the pending task data to obtain the identification of the collection terminal used for task processing, the task identification and the task priority, wherein the pending task data in the message middleware component is pushed by the business service system.
[0042] For example, the business service side ( Figure 3 The business system (i.e., the business service system) pushes task message data (task data to be processed) to the message middleware component kafka, and the data format is JSON; the task message data includes the acquisition terminal device ID, task ID, task priority, task timeout interval, etc.; the scheduling service ( Figure 3The task scheduling system) listens to the task message in kafka and parses the device ID, task ID and task priority. Among them, the task scheduling system is independent of the business service side. The redis structure table (cache database) and the message middleware component kafka can belong to the task scheduling system.
[0043] In the above embodiment, after the scheduling service monitors and receives the task message in Kafka, it parses the device ID, task ID and task priority, and distinguishes each task and device through the device ID, task ID and task priority, thereby ensuring the normal operation of task scheduling.
[0044] The identification of the collection terminal is sent to the notification queue, and the task data to be processed and the task priority are sent to the waiting queue.
[0045] Exemplarily, the scheduling service sends the device ID to the redis notification queue and sends task related information (task priority and JSON data) to the redis waiting queue.
[0046] When the identification of the collection terminal in the notification queue is monitored, the cache database is notified to execute the sent script, wherein the execution of the sent script can achieve: based on the identification of the collection terminal, the number of tasks currently being executed by the collection terminal in the working queue is queried, and when the number of tasks does not exceed the number threshold, the target task data with the highest priority corresponding to the collection terminal is obtained from the waiting queue, and the task identification corresponding to the target task data is written into the working queue. The cache database also includes a timeout queue; the execution of the sent script can also achieve: after obtaining the target task data with the highest priority corresponding to the collection terminal from the waiting queue, the target task data is parsed to obtain the timeout time interval, and the timeout time interval, the identification of the collection terminal and the task identification are written into the timeout queue.
[0047] Exemplarily, the sending script includes redis sending a lua script. After the scheduling service system monitors the redis notification queue message (device ID), the scheduling service system notifies redis to execute the redis sending lua script: use the device ID to query the number of tasks currently being executed by the device from the work queue. If the limit is exceeded (from the configuration), terminate the script and return the task termination identifier to the scheduling service; if the limit is not exceeded, pull and delete the highest priority task JSON data of the device from the waiting queue, parse the timeout time interval from the JSON, and write relevant data to the work queue (relevant data such as task ID) and the timeout queue (relevant data such as timeout time interval, device ID, task ID), where the timeout queue score value is the timeout timestamp, and return the task JSON data to the scheduling service, and the scheduling service determines to continue the sending process (combined with Figure 4 ).
[0048] In the above embodiment, a threshold is set for the number of tasks executed by the device, so that the number of tasks executed simultaneously by a single device is limited by device type, thereby avoiding blocking. A timeout mechanism is designed to reduce the overall running time of the task and improve task execution efficiency.
[0049] If the scheduling service receives the task termination result, it terminates the execution of the task. The scheduling service determines not to continue the delivery process (combined with Figure 4 ) to execute after the existing task is completed or times out.
[0050] If the scheduling service receives the task JSON data and determines to continue the delivery process, after notifying the cache database to execute the delivery script, the target task data is stored as the delivery task data in the delivery data cache area in the cache database.
[0051] For example, write the task message JSON into the redis delivery data cache (delivery task JSON data) and set the expiration time to 1h (taking 1h as an example).
[0052] After executing the sending script, the target task data corresponding to the task identifier in the work queue is processed to obtain the sending protocol message data, including: if the target task data returned from the cache database is received, a frame number that can be parsed by the acquisition terminal is generated based on the identifier of the acquisition terminal; the target task data and the frame number are converted into a protocol to obtain the sending protocol message data.
[0053] Exemplarily, a frame number is generated through a frame number cache according to the device identifier, and the scheduling service assembles the JSON message and frame number and converts its protocol into the 698 protocol or 376.1 protocol, etc., so as to obtain the sent protocol message data that can be recognized by the terminal, so as to send the sent protocol message data to the collection terminal for task processing. The frame number is used to match the data responded by the collection terminal. The data responded by the collection terminal includes the result message obtained by the collection terminal based on the sent protocol message data for task processing; because the collection terminal protocol does not support task ID but supports frame number, it needs to rely on frame number. After the subsequent collection terminal processes the task and obtains the result, it needs to return the result and frame number to the scheduling service. At this time, the scheduling service can determine the corresponding task ID based on the frame number (see the process of the collection terminal processing the task and returning the result below for details).
[0054] In the above embodiment, the JSON message and the frame sequence number are assembled and converted into the sent protocol message data recognizable by the terminal, thereby ensuring the normal operation of the task scheduling.
[0055] The sending of the protocol message data to the collection terminal includes: the task scheduling system sends the sending protocol message data to the front gateway, so that the front gateway sends the sending protocol message data to the collection terminal. The collection terminal performs task processing based on the sending protocol message data to obtain the task execution result.
[0056] For example, Figure 3 As shown, the scheduling service sends the protocol message data to the front-end gateway, and then sends it to the terminal device through the front-end gateway. The terminal device (collection terminal) executes the sent protocol message data to realize task processing and obtain the result message.
[0057] Figure 5 The overall flow chart of normal response to tasks provided in the implementation mode of this specification is as follows: Figure 6 A flowchart of the task normal response scheduling service processing provided in the implementation mode of this specification.
[0058] like Figure 5 , Figure 6 As shown, the task scheduling system receives the task execution result returned by the acquisition terminal, including: the task scheduling system receives the task execution result sent by the front gateway, wherein the task execution result of the front gateway comes from the acquisition terminal. After the scheduling service receives the task execution result returned by the acquisition terminal, it parses the device identifier and frame number from the result message, and obtains the task JSON data corresponding to the frame number from the redis data cache.
[0059] After obtaining the sent task data corresponding to the frame number from the sent data cache area, notify the cache database to execute the response script, wherein the response script can be executed to achieve: deleting the timeout time interval corresponding to the task identifier obtained by parsing, the identifier of the acquisition terminal and the task identifier from the timeout queue, and deleting the sent task data corresponding to the task identifier obtained by parsing from the sent data cache area.
[0060] Exemplarily, the response script includes a redis response lua script, and the redis response lua script is executed to delete task-related data from a redis timeout queue and a redis sent data cache.
[0061] If the task JSON data cannot be obtained through the cache, it means that the task has been processed by the timeout logic (see the task timeout response content below), and there is no need to process the response message.
[0062] Parse the downlink task data corresponding to the frame number in the downlink data buffer area to obtain the uplink normal message data and task identifier; push the uplink normal message data, task identifier and task execution result to the business service system through the message middleware component.
[0063] Exemplarily, the scheduling service parses the downlink task JSON data and converts it into an uplink JSON message. At the same time, it parses the downlink task JSON data to obtain the task ID, assembles the uplink JSON message, task ID and collection terminal task execution results, and pushes the uplink JSON message to the business service system through Kafka.
[0064] After the normal uplink message data, task identifier and task execution result are pushed to the business service system through the message middleware component, an instruction to process the next task is sent to the notification queue.
[0065] In the above embodiment, the frame sequence number can correspond to the sent task data, so that the terminal can correctly respond to the framed message, while avoiding the terminal's rejection response caused by receiving a large number of commands.
[0066] Figure 7 The overall flow chart of task timeout response provided in the implementation mode of this specification is as follows: Figure 8 This is a flowchart of the task timeout response scheduling service processing provided in the implementation mode of this specification.
[0067] like Figure 7 , Figure 8 As shown, the timeout script includes a redis timeout lua script. By executing the timeout script, it is possible to: determine the timed-out target task data based on the timeout time interval in the timeout queue; obtain the identification and task identification of the collection terminal corresponding to the timed-out target task data, and delete the timed-out target task data from the timeout queue.
[0068] Based on the task identifier corresponding to the timed-out target task data, the task identifier in the work queue is deleted.
[0069] Exemplarily, the scheduling service monitors the redis timeout queue and obtains the timed-out device ID and task ID based on the timeout period, and deletes the task message in the timeout queue; and deletes the matching task information in the work queue of the collection terminal device through these two parameters (device ID and task ID).
[0070] Based on the identifier of the collection terminal corresponding to the timed target task data, the task identifier and the timeout information, an uplink timeout message is obtained.
[0071] Exemplarily, the task ID, device ID, and timeout information are assembled to obtain a timed-out uplink JSON message, and the uplink JSON message is pushed to Kafka to the business service system.
[0072] The uplink timeout message is pushed to the business service system through the message middleware component, and an instruction to process the next task is sent to the notification queue.
[0073] Exemplarily, data is sent to the redis notification queue to notify the device to process the next message, thereby avoiding the problem that the subsequent tasks cannot be executed due to reaching the upper limit of the work queue.
[0074] In the above embodiment, by executing the timeout script, the target task data in the timeout queue and the task identifier in the work queue are deleted, which can save space resources of the cache database, achieve fast response to timeout, and reduce the possibility of task queue blocking.
[0075] The above embodiment is applicable to the task scheduling scenario of equipment in the power industry collection terminal, based on JAVA microservice technology, redis cache database, and kafka message middleware components; the notification queue method is used to notify the task scheduling service to pull the data to be sent; the task scheduling service processes multiple nodes concurrently to improve the task execution efficiency when there are a large number of tasks, and the number of tasks that can be executed simultaneously by a single device can be limited according to the device type; multiple redis operations are encapsulated into a single lua script to achieve the atomicity of business operations, avoiding the problem of repeated operations or failure to find related data caused by repeated data processing by multiple cluster nodes (service nodes) of the task scheduling service; a timeout mechanism is used, and if the collection terminal does not respond within a specific time, it will fail quickly, reducing task blocking and improving the overall task operation efficiency.
[0076] Fig. 9 A schematic diagram of a task scheduling device provided in an implementation manner of this specification.
[0077] This specification embodiment provides a task scheduling device 900, see Fig. 9 The task scheduling device 900 includes: a monitoring and parsing module 910, a sending module 920, a notification execution module 930 and a message obtaining and sending module 940.
[0078] Exemplarily, the monitoring and parsing module 910 is used to parse and process the pending task data when monitoring the pending task data in the message middleware component, and obtain the identification of the collection terminal used for task processing, the task identification and the task priority, wherein the pending task data in the message middleware component is pushed by the business service system.
[0079] Exemplarily, the sending module 920 is used to send the identifier of the collection terminal to the notification queue, and send the to-be-processed task data and the task priority to the waiting queue.
[0080] Exemplarily, the notification execution module 930 is used to notify the cache database to execute the sent script when the identifier of the collection terminal in the notification queue is monitored, wherein the execution of the sent script can achieve: based on the identifier of the collection terminal, query the number of tasks currently being executed by the collection terminal in the working queue, and when the number of tasks does not exceed the number threshold, obtain the highest priority target task data corresponding to the collection terminal from the waiting queue, and write the task identifier corresponding to the target task data into the working queue.
[0081] Exemplarily, the message acquisition and sending module 940 is used to process the target task data corresponding to the task identifier in the work queue to obtain the sent protocol message data after executing the sent script, and send the sent protocol message data to the collection terminal, so that the collection terminal performs task processing based on the sent protocol message data to obtain the task execution result.
[0082] It can be understood that for the specific description of the task scheduling device 900, reference can be made to the description of the task scheduling method above, which will not be repeated here.
[0083] An embodiment of the present specification provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method in any of the above embodiments are implemented.
[0084] An embodiment of the present specification provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method in any of the above embodiments are implemented.
[0085] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0086] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0087] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0088] In the description of the present invention, it is to be understood that the terms “center”, “longitudinal”, “lateral”, “length”, “width”, “thickness”, “up”, “down”, “front”, “back”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, “clockwise”, “counterclockwise”, “axial”, “radial”, “circumferential”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0089] In addition, the terms "first", "second", etc. used in the embodiments of the present invention are only used for descriptive purposes and should not be understood as indicating or implying relative importance, or implicitly indicating the number of technical features indicated in the present embodiment. Therefore, the features defined by the terms "first", "second", etc. in the embodiments of the present invention can explicitly or implicitly indicate that the embodiment includes at least one of the features. In the description of the present invention, the word "multiple" means at least two or two or more, such as two, three, four, etc., unless otherwise clearly and specifically defined in the embodiments.
[0090] In the present invention, unless otherwise clearly specified or limited in the embodiments, the terms "installed", "connected", "connected" and "fixed" etc. in the embodiments should be understood in a broad sense. For example, the connection can be a fixed connection, a detachable connection, or an integrated connection. It can be understood that it can also be a mechanical connection, an electrical connection, etc.; of course, it can also be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal connection of two elements, or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to the specific implementation situation.
[0091] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0092] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A task scheduling method, characterized in that: The method is applied to a task scheduling system, the task scheduling system can communicate data with a cache database, the cache database at least includes a notification queue, a waiting queue and a work queue, and the method includes: When monitoring the pending task data in the message middleware component, the pending task data is parsed to obtain the identification of the collection terminal for task processing, the task identification and the task priority, wherein the pending task data in the message middleware component is pushed by the business service system; Sending the identification of the acquisition terminal to the notification queue, and sending the to-be-processed task data and the task priority to the waiting queue; In case of monitoring the identifier of the acquisition terminal in the notification queue, the cache database is notified to execute the issued script, wherein the execution of the issued script can achieve: based on the identifier of the acquisition terminal, query the number of tasks currently being executed by the acquisition terminal in the working queue, and in case the number of tasks does not exceed the number threshold, obtain the target task data with the highest priority corresponding to the acquisition terminal from the waiting queue, and write the task identifier corresponding to the target task data into the working queue; After executing the sending script, the target task data corresponding to the task identifier in the work queue is processed to obtain sending protocol message data, and the sending protocol message data is sent to the acquisition terminal, so that the acquisition terminal performs task processing based on the sending protocol message data to obtain the task execution result.
2. The task scheduling method according to claim 1, characterized in that: The cache database also includes a timeout queue; by executing the issued script, the following can also be achieved: After obtaining the target task data with the highest priority corresponding to the collection terminal from the waiting queue, the target task data is parsed to obtain a timeout time interval, and the timeout time interval, the identifier of the collection terminal and the task identifier are written into the timeout queue.
3. The task scheduling method according to claim 1 or 2, characterized in that: After executing the sending script, processing the target task data corresponding to the task identifier in the work queue to obtain sending protocol message data includes: After executing the issued script, if the target task data returned from the cache database is received, a frame sequence number that can be parsed by the acquisition terminal is generated based on the identifier of the acquisition terminal; The target task data and the frame sequence number are subjected to protocol conversion to obtain the sent protocol message data.
4. The task scheduling method according to claim 3, characterized in that: The method further comprises: After notifying the cache database to execute the delivery script, storing the target task data as the delivery task data in the delivery data cache area in the cache database; After receiving the task execution result returned by the acquisition terminal, parsing the task execution result to obtain the frame sequence number; Acquire the sending task data corresponding to the frame sequence number from the sending data buffer area; Parsing the downlink task data corresponding to the frame sequence number in the downlink data buffer area to obtain uplink normal message data and a task identifier; The uplink normal message data, the task identifier and the task execution result are pushed to the business service system through a message middleware component.
5. The task scheduling method according to claim 4, characterized in that: The method further comprises: After acquiring the dispatch task data corresponding to the frame sequence number from the dispatch data buffer area, notifying the cache database to execute a response script, wherein the response script can be executed to achieve: deleting the timeout time interval corresponding to the task identifier obtained by parsing, the identifier of the acquisition terminal and the task identifier from the timeout queue, and deleting the dispatch task data corresponding to the task identifier obtained by parsing from the dispatch data buffer area; After the uplink normal message data, the task identifier and the task execution result are pushed to the business service system through the message middleware component, an instruction for processing the next task is sent to the notification queue.
6. The task scheduling method according to claim 1, 2, 4 or 5, characterized in that: The method further comprises: Notify the cache database to execute a timeout script, wherein, by executing the timeout script, it is possible to achieve: determine the timed-out target task data based on the timeout time interval in the timeout queue; obtain the identification of the acquisition terminal and the task identification corresponding to the timed-out target task data, and delete the timed-out target task data from the timeout queue; based on the task identification corresponding to the timed-out target task data, delete the task identification in the work queue; Based on the identifier of the acquisition terminal corresponding to the timed target task data, the task identifier and the timeout information, an uplink timeout message is obtained; The uplink timeout message is pushed to the business service system through a message middleware component, and an instruction for processing the next task is sent to the notification queue.
7. The task scheduling method according to claim 1, 2, 4 or 5, characterized in that: The task scheduling system includes multiple service nodes, and the multiple service nodes can perform task scheduling concurrently; each acquisition terminal can execute multiple tasks at the same time.
8. The task scheduling method according to claim 4 or 5, characterized in that: The sending of the issued protocol message data to the collection terminal comprises: the task scheduling system sending the issued protocol message data to a front-end gateway, so that the front-end gateway sends the issued protocol message data to the collection terminal; The receiving of the task execution result returned by the collection terminal includes: the task scheduling system receiving the task execution result sent by the front-end gateway, wherein the task execution result of the front-end gateway comes from the collection terminal.
9. A task scheduling device, characterized in that: The device comprises: A monitoring and parsing module is used to parse and process the pending task data in the message middleware component when monitoring the pending task data, and obtain the identification of the collection terminal used for task processing, the task identification and the task priority, wherein the pending task data in the message middleware component is pushed by the business service system; A sending module, used for sending the identification of the acquisition terminal to the notification queue, and sending the to-be-processed task data and the task priority to the waiting queue; A notification execution module is used to notify the cache database to execute the issued script when the identifier of the acquisition terminal in the notification queue is monitored, wherein the execution of the issued script can achieve: based on the identifier of the acquisition terminal, query the number of tasks currently being executed by the acquisition terminal in the work queue, and when the number of tasks does not exceed the number threshold, obtain the target task data with the highest priority corresponding to the acquisition terminal from the waiting queue, and write the task identifier corresponding to the target task data into the work queue; The message acquisition and sending module is used to process the target task data corresponding to the task identifier in the work queue to obtain the sending protocol message data after executing the sending script, and send the sending protocol message data to the acquisition terminal, so that the acquisition terminal performs task processing based on the sending protocol message data to obtain the task execution result.
10. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Cross-platform distributed task scheduling system and scheduling method
CN113157420A
Method and equipment for realizing remote data acquisition
CN113961367A
Method, device and equipment for collecting electric power data of massive electric power terminals
CN116170516A
Message queueing in middleware by a message broker
US9928125B1