Task scheduling method and device, electronic equipment and storage medium
By designing queues and implementing timeout mechanisms in the task scheduling system and cache database, the problem of low single-task execution efficiency of the acquisition terminal was solved, enabling multi-task concurrency and stable response, thereby improving the terminal's task execution efficiency and system stability.
Patent Information
- Application Number
- CN202411463180.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2044-10-18
AI Technical Summary
In existing technologies, the data acquisition terminal can only execute a single task at a time, leading to repeated concurrent execution of tasks and abnormal responses. This is especially true when there are many service nodes, resulting in low task execution efficiency and poor stability.
The system employs a task scheduling system that communicates with a cache database. Through the design of notification queues, waiting queues, and work queues, each acquisition terminal is allowed to execute multiple tasks at the same time. Furthermore, timeout mechanisms and frame sequence number mechanisms are introduced to ensure the stability and efficient execution of tasks.
This improves the task execution efficiency of the data acquisition terminal, reduces the possibility of task blocking and repeated execution, and enhances the stability and response speed of the system.
Smart Images

Figure CN119376884B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of power collection, and particularly relates to a task scheduling method and device, electronic equipment and a storage medium. BACKGROUND
[0002] With the development and application of big data, artificial intelligence, cloud computing and other technologies, a new generation of power consumption information collection system has core capabilities such as security authentication, full collection, dispatching control, mass storage, real-time analysis, and global monitoring. In the face of the access of a large number of collection terminal devices and the demand for remote dispatching services, higher requirements are put forward for terminal dispatching management in terms of high performance, high availability, security and stability.
[0003] The related technical solution can only execute a single task at the same time, and other tasks need to be queued or even rejected at the terminal side. In the case of a large number of service nodes, there is a possibility of repeated concurrent execution of tasks. SUMMARY
[0004] The embodiments of the present application aim to at least solve one of the technical problems in the related art. To this end, one object of the present application is to provide a task scheduling method, device, electronic equipment and storage medium that can improve execution efficiency and support fast response in case of timeout.
[0005] The embodiments of the present application provide a task scheduling method, which is applied to a task scheduling system capable of communicating data with a cache database, the cache database at least including a notification queue, a waiting queue and a working queue. The task scheduling method comprises: in the case of listening to the to-be-processed task data in the message middleware component, performing analysis processing on the to-be-processed task data to obtain the identifier of the collection terminal, the task identifier and the task priority for processing the task, wherein the to-be-processed task data in the message middleware component is pushed by a business service system; sending the identifier of the collection terminal to the notification queue, and sending the to-be-processed task data and the task priority to the waiting queue; in the case of listening to the identifier of the collection terminal in the notification queue, notifying the cache database to execute a delivery script, wherein by executing the delivery script, the following can be achieved: based on the identifier of the collection terminal, the number of tasks currently being executed by the collection terminal in the working queue is queried, and in the case that the number of tasks does not exceed a quantity threshold, the target task data corresponding to the collection terminal with the highest priority is obtained from the waiting queue, and the task identifier corresponding to the target task data is written into the working queue; after executing the delivery script, the target task data corresponding to the task identifier in the working queue is processed to obtain delivery protocol message data, and the delivery protocol message data is sent to the collection terminal, so that the collection terminal performs task processing based on the delivery protocol message data to obtain a task execution result.
[0006] Exemplarily, the cache database further comprises a timeout queue; by executing the delivery script, the following can also be achieved: after obtaining the target task data corresponding to the terminal with the highest priority from the waiting queue, the timeout interval is obtained by parsing the target task data, and the timeout interval, the identifier of the terminal and the task identifier are written into the timeout queue.
[0007] Exemplarily, after executing the delivery script, the target task data corresponding to the task identifier in the working queue is processed to obtain the delivery protocol message data, including: after executing the delivery script, if the target task data returned from the cache database is received, the frame number that the terminal can parse is generated based on the identifier of the terminal; the target task data and the frame number are protocol converted to obtain the delivery protocol message data.
[0008] Exemplarily, the task scheduling method further comprises: after notifying the cache database to execute the delivery script, the target task data is stored as delivery task data in the delivery data cache area in the cache database; after receiving the task execution result returned by the terminal, the frame number is obtained by parsing the task execution result; the delivery task data corresponding to the frame number is obtained from the delivery data cache area; the delivery task data corresponding to the frame number in the delivery data cache area is parsed to obtain the uplink normal message data and the task identifier; 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.
[0009] Exemplarily, the task scheduling method further comprises: after obtaining the delivery task data corresponding to the frame number from the delivery data cache area, notifying the cache database to execute the response script, wherein by executing the response script, the following can be achieved: the timeout interval corresponding to the task identifier obtained by parsing, the identifier of the terminal and the task identifier are deleted from the timeout queue, and the delivery task data corresponding to the task identifier obtained by parsing is deleted from the delivery data cache area; after pushing the uplink normal message data, the task identifier and the task execution result to the business service system through the message middleware component, an instruction of processing the next task is sent to the notification queue.
[0010] Exemplarily, the task scheduling method further comprises: notifying the cache database to execute a timeout script, wherein, by executing the timeout script, the following can be achieved: determining the target task data that is timed out based on the timeout time interval in the timeout queue; obtaining the identifier of the collection terminal and the task identifier corresponding to the target task data that is timed out, and deleting the target task data that is timed out from the timeout queue; deleting the task identifier in the work queue based on the task identifier corresponding to the target task data that is timed out; obtaining the uplink timeout message based on the identifier of the collection terminal, the task identifier and the timeout information corresponding to the target task data that is timed out; 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 comprises a plurality of service nodes, and the plurality of service nodes can concurrently perform task scheduling; each collection terminal can execute a plurality of tasks at the same time.
[0012] Exemplarily, sending the downlink protocol message data to the collection terminal comprises: the task scheduling system sending the downlink protocol message data to the front-end gateway, so that the front-end gateway sends the downlink protocol message data to the collection terminal; receiving the task execution result returned by the collection terminal comprises: 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 is from the collection terminal.
[0013] The embodiment of the present specification provides a task scheduling device, which comprises: a listening and analyzing module, configured to analyze and process the to-be-processed task data in the message middleware component to obtain the identifier of the collection terminal, the task identifier and the task priority for processing the task, wherein the to-be-processed task data in the message middleware component is pushed by the business service system; a sending module, configured 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; a notification execution module, configured to notify the cache database to execute a downlink script in the case of listening to the identifier of the collection terminal in the notification queue, wherein, by executing the downlink script, the following can be achieved: querying the number of tasks that the collection terminal is currently executing in the work queue based on the identifier of the collection terminal, and in the case that the number of tasks does not exceed the number threshold, obtaining the target task data corresponding to the collection terminal with the highest priority from the waiting queue, and writing the task identifier corresponding to the target task data into the work queue; a message obtaining and sending module, configured to process the target task data corresponding to the task identifier in the work queue to obtain the downlink protocol message data after executing the downlink script, and send the downlink protocol message data to the collection terminal, so that the collection terminal processes the task based on the downlink protocol message data to obtain the task execution result.
[0014] The electronic device provided by the embodiments of the present specification includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the method of any one of the above embodiments when executing the computer program.
[0015] The computer-readable storage medium provided by the embodiments of the present specification stores a computer program, and the processor implements the steps of the method of any one of the above embodiments when executing the computer program.
[0016] In the above embodiments of the present specification, the task scheduling method includes: in the case of listening to the to-be-processed task data in the message middleware component, performing analysis processing on the to-be-processed task data to obtain the identifier of the collection terminal, the task identifier and the task priority for performing task processing, wherein the to-be-processed task data in the message middleware component is pushed by the business service system; sending the identifier of the collection terminal to the notification queue, and sending the to-be-processed task data and the task priority to the waiting queue; in the case of listening to the identifier of the collection terminal in the notification queue, notifying the cache database to execute the delivery script, wherein by executing the delivery script, the following can be achieved: based on the identifier of the collection terminal, the number of tasks currently being executed by the collection terminal in the work queue is queried, in the case that the number of tasks does not exceed the number threshold, the target task data corresponding to the collection terminal with the highest priority is obtained from the waiting queue, and the task identifier corresponding to the target task data is written to the work queue; after executing the delivery script, the target task data corresponding to the task identifier in the work queue is processed to obtain the delivery protocol message data, and the delivery protocol message data is sent to the collection terminal, so that the collection terminal performs task processing based on the delivery protocol message data to obtain the task execution result. The above task scheduling method optimizes the task scheduling of the server, realizes that the collection terminal can execute multiple different tasks at the same time, and improves the execution efficiency of the terminal side.
[0017] Additional aspects and advantages of the application will be set forth in part in the description which follows, and in part will become apparent to those skilled in the art upon examination of the following and / or can be learned by practice of the application. BRIEF DESCRIPTION OF DRAWINGS
[0018] Figure 1 A cache database redis structure diagram provided by the embodiments of the present specification;
[0019] Figure 2 A flowchart of the task scheduling method provided by the embodiments of the present specification;
[0020] Figure 3 A task delivery overall flowchart provided by the embodiments of the present specification;
[0021] Figure 4 A task delivery scheduling service processing flowchart provided by the embodiments of the present specification;
[0022] Figure 5 Task normal response overall flowchart provided for the embodiments of the present description;
[0023] Figure 6 Task normal response dispatch service processing flowchart provided for the embodiments of the present description;
[0024] Figure 7 Task timeout response overall flowchart provided for the embodiments of the present description;
[0025] Figure 8 Task timeout response dispatch service processing flowchart provided for the embodiments of the present description;
[0026] Figure 9 Task scheduling device schematic diagram provided for the embodiments of the present description. DETAILED DESCRIPTION
[0027] Embodiments of the present application are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numbers represent the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by reference to the accompanying drawings are exemplary and are intended to explain the present application, and cannot be understood as a limitation of the present application.
[0028] With the development and application of technologies such as big data, artificial intelligence, cloud computing, etc., the new generation of power consumption information collection system has core capabilities such as security authentication, full collection, dispatching control, mass storage, real-time analysis, and global monitoring. In the face of the access of a large number of collection terminal devices and the demand for remote dispatching business, higher requirements are put forward for terminal dispatching management in terms of high performance, high availability, security, and stability.
[0029] The related technical solution can only execute a single task at the same time for the collection terminal, and other tasks need to be queued or even rejected at the collection terminal side; if the collection terminal appears to be stuck, offline, or abnormal in response during the execution of a certain task, the timeout mechanism cannot ensure that the task in the device order can get the opportunity to be executed; in the case of a large number of service nodes (the task scheduling system includes multiple service nodes, and the service node can be a server) existing in the task scheduling system, there is a possibility that the same task is repeatedly and concurrently executed by multiple service nodes; when the volume of a single message responded by the collection terminal is large, the terminal will respond in frames, and if the terminal receives a new task at this time, it will cause the interruption of the ongoing framing, and the data collection will not be complete; at the same time, issuing a large number of instructions will cause the terminal to refuse to respond.
[0030] To this end, the embodiment of the present specification provides a task scheduling method, which carries out remote task management to the collection terminal through a cloud platform system (task scheduling system), guarantees the stability of the task through the expansion of the service node when facing a large number of tasks, reduces the task blocking situation through the limitation of the number of concurrent instructions of a single device, designs a timeout mechanism to reduce the overall running time of the task, and improves the task execution efficiency.
[0031] The task scheduling method of the power collection terminal provided by the present application includes a task issuing process and a task response process, wherein the task response process is divided into two types: normal task response and timeout task response. The task scheduling method is applied to a task scheduling system, which can communicate data with a cache database. The cache database includes at least a notification queue, a waiting queue, and a working queue. The task scheduling system includes multiple service nodes, which can concurrently schedule tasks. 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 shown in Figure 1 The notification queue has a device ID (the identifier of the collection terminal) as its attribute value, the waiting queue has a task priority and an issued task information JSON data (to-be-processed task data) as its attribute value, the working queue has a task ID (task identifier) as its attribute value, the timeout queue has a timeout task timestamp (seconds) and a device ID#task ID (# represents a connector, used to separate the device ID and the task ID) as its attribute value, the frame number cache has an auto-increment integer as its attribute value, and the issued data cache has an issued task JSON data as its attribute value. The task scheduling system provides multiple service nodes, which can concurrently execute task scheduling.
[0033] In the above embodiment, the cache database includes multiple queue forms, each queue is responsible for completing a specific function, and the division of labor is clear; the task scheduling system has multiple service nodes, which can concurrently execute task scheduling and improve the task execution efficiency when a large number of tasks are executed.
[0034] Figure 2 The flowchart of the task scheduling method provided by the embodiment of the present specification is shown in
[0035] As shown in Figure 2 The task scheduling method 200 of the present specification includes steps S210-S240.
[0036] Step S210, in the case of listening to the to-be-processed task data in the message middleware component, the to-be-processed task data is parsed and processed to obtain the identifier of the collection terminal, the task identifier and the task priority for task processing. The to-be-processed task data in the message middleware component is pushed by the business service system.
[0037] Step S220, the identifier of the collection terminal is sent to the notification queue, and the to-be-processed task data and the task priority are sent to the waiting queue.
[0038] Step S230, in the case of listening to the identifier of the collection terminal in the notification queue, the cache database is notified to execute the delivery script. Through the execution of the delivery script, the following can be achieved: based on the identifier of the collection terminal, the number of tasks currently being executed by the collection terminal in the work queue is queried, in the case that the number of tasks does not exceed the number threshold, the target task data corresponding to the collection terminal with the highest priority is obtained from the waiting queue, and the task identifier corresponding to the target task data is written to the work queue.
[0039] Step S240, after executing the delivery script, the target task data corresponding to the task identifier in the work queue is processed to obtain the delivery protocol message data, and the delivery protocol message data is sent to the collection terminal, so that the collection terminal performs task processing based on the delivery protocol message data to obtain the task execution result.
[0040] Figure 3 The task delivery overall flowchart provided for the embodiments of the present specification, Figure 4 The task delivery scheduling service processing flowchart provided for the embodiments of the present specification.
[0041] As shown in Figure 3 , Figure 4 The task delivery scheduling service processing flowchart includes, in the case of listening to the to-be-processed task data in the message middleware component, the to-be-processed task data is parsed and processed to obtain the identifier of the collection terminal, the task identifier and the task priority for task processing, wherein the to-be-processed task data in the message middleware component is pushed by the business service system.
[0042] Exemplarily, the business system on the business service side (i.e. the business service system) pushes the task message data (to-be-processed task data) to the message middleware component kafka, and the data format is JSON; the task message data includes the collection terminal device ID, the task ID and the task priority, the task timeout time interval, etc.; the scheduling service (i.e. the scheduling service) listens to the to-be-processed task data in the message middleware component, and the to-be-processed task data is parsed and processed to obtain the identifier of the collection terminal, the task identifier and the task priority for task processing. Figure 3 Figure 3 The task scheduling system listens to the task message in the kafka, and parses the device ID, task ID and task priority. The task scheduling system is independent of the business service side, and the redis structure table (cache database) and the message middleware component kafka can belong to the task scheduling system.
[0043] In the above embodiment, the scheduling service listens to the task message in the kafka, 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 identifier of the collection terminal is sent to the notification queue, and the to-be-processed task data and the task priority are sent to the waiting queue.
[0045] The scheduling service sends the device ID to the redis notification queue and sends the task related information (task priority and JSON data) to the redis waiting queue.
[0046] In the case of listening to the identifier of the collection terminal in the notification queue, the cache database is executed to issue a script, and the script is executed to query the number of tasks currently executed by the collection terminal in the work queue based on the identifier of the collection terminal, and in the case that the number of tasks does not exceed the number threshold, the target task data corresponding to the collection terminal with the highest priority is obtained from the waiting queue, and the task identifier corresponding to the target task data is written into the work queue. The cache database further includes a timeout queue, and the script is executed to parse the target task data to obtain a timeout interval, and the timeout interval, the identifier of the collection terminal and the task identifier are written into the timeout queue.
[0047] The scheduling service system listens to the redis notification queue message (device ID), and the scheduling service system notifies the redis to execute the redis issue lua script: the device ID is used to query the number of tasks currently executed by the device from the work queue, if the number of tasks exceeds the limit number (from the configuration), the script is terminated and the task termination identifier is returned to the scheduling service; if the number of tasks does not exceed the limit number, the task JSON data with the highest priority of the device is pulled and deleted from the waiting queue, the timeout interval is parsed from the JSON, and the related data such as the task ID is written into the work queue and the timeout queue (the related data such as the timeout interval, the device ID and the task ID), the score value of the timeout queue is the timeout timestamp, and the task JSON data is returned to the scheduling service, and the scheduling service judges to continue the issue process (combined with Figure 4 ). Figure 4 ).
[0048] In the above embodiment, the number of tasks executed by the device is set with a threshold, the number of tasks simultaneously executed by a single device is limited according to the type of the device, the occurrence of blocking is avoided, the timeout mechanism is designed to reduce the overall running time of the task, and the efficiency of task execution is improved.
[0049] If the scheduling service receives the task termination result, the execution of the task is terminated, the scheduling service judges to continue to issue the process, and the existing task is completed or timed out. Figure 4 ), and then executes.
[0050] If the scheduling service receives the task JSON data, it is judged to continue to issue the process, and after notifying the cache database to execute the issuing script, the target task data is stored as issuing task data in the issuing data cache area in the cache database.
[0051] For example, the task message JSON is written into the redis issuing data cache (issuing task JSON data) and the expiration time is set to 1h (for example, 1h).
[0052] After executing the issuing script, the target task data corresponding to the task identifier in the work queue is processed to obtain the issuing protocol message data, including: if the target task data returned from the cache database is received, the frame sequence number that the collection terminal can parse is generated based on the identifier of the collection terminal; the target task data and the frame sequence number are protocol converted to obtain the issuing protocol message data.
[0053] Exemplarily, the frame sequence number is generated through the frame sequence number cache according to the device identifier, the scheduling service assembles the JSON message and the frame sequence number and converts them into 698 protocol or 376.1 protocol, etc., so as to obtain the issuing protocol message data recognizable by the terminal, so as to send the issuing protocol message data to the collection terminal for task processing. The frame sequence number is used to match the data responded by the collection terminal, and the data responded by the collection terminal includes the result message obtained by the collection terminal based on the issuing protocol message data for task processing; since the collection terminal protocol does not support task ID, it supports frame sequence number, so it needs to rely on frame sequence number, and after the collection terminal processes the task to obtain the result, the result and the frame sequence number need to be returned to the scheduling service, at this time the scheduling service can determine the corresponding task ID based on the frame sequence number (for details, see the process of the collection terminal processing the task and returning the result below).
[0054] In the above embodiment, the JSON message and the frame sequence number are assembled and converted into the issuing protocol message data recognizable by the terminal, ensuring the normal operation of task scheduling.
[0055] The task scheduling system sends the protocol message data to the front-end gateway, and the front-end gateway sends the protocol message data to the collection terminal. The collection terminal processes the task based on the protocol message data to obtain a task execution result.
[0056] As shown in Figure 3 , the scheduling service sends the protocol message data to the front-end gateway, and the front-end gateway sends the protocol message data to the terminal device. The terminal device (collection terminal) executes the protocol message data to implement task processing and obtain a result message.
[0057] Figure 5 A task normal response overall flowchart provided for the embodiment of the present specification is shown in Figure 6 A task normal response scheduling service processing flowchart provided for the embodiment of the present specification is shown in
[0058] As shown in Figure 5 , Figure 6 The task scheduling system receives the task execution result returned by the collection terminal, including: 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 is from the collection terminal. After the scheduling service receives the task execution result returned by the collection terminal, the device identifier and the frame sequence number are parsed from the result message, and the task JSON data corresponding to the frame sequence number is obtained from the redis data cache.
[0059] After obtaining the task data corresponding to the frame sequence number from the data cache area, the cache database is notified to execute the response script, wherein by executing the response script, the following can be achieved: deleting the timeout time interval corresponding to the task identifier, the identifier of the collection terminal and the task identifier from the timeout queue, and deleting the task data corresponding to the task identifier from the data cache area.
[0060] As an example, the response script includes a redis response lua script, and the redis response lua script is executed to delete the task related data from the redis timeout queue and the redis data cache.
[0061] If the task JSON data cannot be obtained through the cache, it means that the task is processed by the timeout logic (see the task timeout response content below), and at this time, the response message does not need to be processed.
[0062] The task data corresponding to the frame sequence number in the data cache area is parsed to obtain the uplink normal message data and the task identifier; 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.
[0063] Exemplarily, the scheduling service parses the issued task JSON data and converts it into an uplink JSON message, simultaneously parses the issued task JSON data to obtain a task ID, assembles the uplink JSON message, the task ID and the task execution result of the collection terminal, and pushes the uplink JSON message to the business service system through the kafka.
[0064] 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 of processing the next task is sent to the notification queue.
[0065] In the above embodiment, the frame sequence number can correspond to the issued task data, so that the terminal can correctly respond to the framed message, and meanwhile, the refusal response caused by the terminal receiving a large number of commands is avoided.
[0066] Figure 7 A task timeout response overall flowchart provided for the embodiment of the present specification, Figure 8 A task timeout response scheduling service processing flowchart provided for the embodiment of the present specification.
[0067] As shown in Figure 7 , Figure 8 The timeout script includes a redis timeout lua script, and by executing the timeout script, the following can be achieved: determining the target task data to be timed out based on the timeout time interval in the timeout queue; obtaining the identifier of the collection terminal and the task identifier corresponding to the target task data to be timed out, and deleting the target task data to be timed out from the timeout queue.
[0068] Based on the task identifier corresponding to the target task data to be timed out, the task identifier in the work queue is deleted.
[0069] Exemplarily, the scheduling service listens to the redis timeout queue, obtains the device ID and the task ID based on the timeout time, and deletes the task message in the timeout queue; the task information matched in the work queue of the collection terminal device is deleted through the two parameters (the device ID and the task ID).
[0070] Based on the identifier of the collection terminal, the task identifier and the timeout information corresponding to the target task data to be timed out, an uplink timeout message is obtained.
[0071] Exemplarily, the task ID, the device ID and the timeout information are assembled to obtain an uplink timeout JSON message, and the uplink timeout JSON message is pushed to the business service system through the kafka.
[0072] The uplink timeout message is pushed to the business service system through the message middleware component, and an instruction of processing the next task is sent to the notification queue.
[0073] Exemplarily, the redis notification queue is sent with data, the next packet of the device is notified to be processed, and the problem that subsequent tasks cannot be executed due to reaching the upper limit of the work queue is avoided.
[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, the space resources of the cache database are saved, the timeout fast response is realized, and the possibility of task queue blocking is reduced.
[0075] The above embodiment is applicable to the task scheduling scene of the device of the power industry collection terminal, is based on JAVA micro-service technology and redis cache database and kafka message middleware components, adopts the notification queue mode to notify the task scheduling service to pull the data to be sent, the task scheduling service is processed in multiple nodes in parallel, the task execution efficiency is improved when a large number of tasks, the number of tasks executed by a single device at the same time can be limited according to the device type, a plurality of redis operations are encapsulated into a single lua script to realize the atomicity of business operation, and the problem of repeated operation or failure to find associated data caused by repeated processing of data by multiple cluster nodes (service nodes) of the task scheduling service is avoided, a timeout mechanism is adopted, if the collection terminal does not respond within a specific time, the task is failed quickly, the task blocking condition is reduced, and the overall task running efficiency is improved.
[0076] Figure 9 A task scheduling device schematic diagram provided by the embodiment of the present specification is provided.
[0077] The embodiment of the present specification provides a task scheduling device 900, please refer to Figure 9 The task scheduling device 900 comprises a listening and analyzing module 910, a sending module 920, a notification execution module 930 and a packet obtaining and sending module 940.
[0078] Exemplarily, the listening and analyzing module 910 is used for, in the case of listening to the to-be-processed task data in the message middleware component, analyzing and processing the to-be-processed task data to obtain the identifier of the collection terminal, the task identifier and the task priority for task processing, wherein the to-be-processed task data in the message middleware component is pushed by the business service system.
[0079] Exemplarily, the sending module 920 is used for sending the identifier of the collection terminal to the notification queue, and sending the to-be-processed task data and the task priority to the waiting queue.
[0080] Illustratively, the notification execution module 930 is configured to notify the cache database to execute the delivery script in a case where the identifier of the collection terminal is collected in the notification queue. Through execution of the delivery script, the number of tasks currently executed by the collection terminal in the work queue can be queried based on the identifier of the collection terminal, and in a case where the number of tasks does not exceed the number threshold, the target task data corresponding to the collection terminal with the highest priority is obtained from the waiting queue, and the task identifier corresponding to the target task data is written into the work queue.
[0081] Illustratively, the message obtaining and sending module 940 is configured to process the target task data corresponding to the task identifier in the work queue to obtain the delivery protocol message data after execution of the delivery script, and send the delivery protocol message data to the collection terminal, so that the collection terminal performs task processing based on the delivery protocol message data to obtain the task execution result.
[0082] It can be understood that the specific description of the task scheduling device 900 can refer to the description of the task scheduling method in the foregoing, and will not be described herein.
[0083] The embodiment of the present specification provides an electronic device, comprising a memory and a processor, the memory stores a computer program, and the processor implements the steps of the method in any one of the above embodiments when executing the computer program.
[0084] The embodiment of the present specification provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the method in any one of the above embodiments.
[0085] It is to be appreciated that the above description and the examples that follow are intended to be illustrative only and that changes can be made to the description and examples without departing from the scope of the application. Note also that the use of particular brand names in the description is solely for illustration and should not be construed as an endorsement of such brands.
[0086] It should be understood that aspects of the application can be implemented in hardware, software, firmware or a combination thereof. In the above embodiments, various steps or methods can be implemented in software or firmware that is stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any of the following technologies, known in the art, can be used: a hybrid of the technologies mentioned above, discrete logic circuitry having logic gates for implementing logic functions upon data signals, application specific integrated circuits having appropriate combinational logic gates, programmable gate arrays (PGA), field programmable gate arrays (FPGA), and so forth.
[0087] In the description of the present application, the terms "one embodiment", "some embodiments", "an example", "a specific example", or "some examples" are intended to mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present application. The illustrative appearances of the above terms in various places in the specification are not intended to exclude that each term should be interpreted in the context of the specific embodiment or example where the term is used. Also, the described specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0088] In the description of the present application, it needs to be understood that the terms "center", "longitudinal", "transverse", "length", "width", "thickness", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, which are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as limiting the present application.
[0089] In addition, the terms "first", "second", and the like used in the embodiments of the present application are only for the purpose of description, and cannot be understood as indicating or implying relative importance, or implicitly indicating the number of technical features referred to in the embodiments. Therefore, the features defined with "first", "second" and the like in the embodiments of the present application can be explicitly or implicitly indicated to include at least one of the features. In the description of the present application, the meaning of the word "plurality" is at least two or two or more, such as two, three, four, etc., unless otherwise specifically limited in the embodiments.
[0090] In the present application, unless otherwise specifically provided or limited in the embodiments, the terms "mounting", "connecting", "connecting" and "fixing" and the like appearing in the embodiments should be understood broadly, for example, the connection can be fixed connection, or detachable connection, or integral, which can be understood, or can be mechanical connection, electrical connection, etc. Of course, it can also be directly connected, or indirectly connected through an intermediate medium, or the internal communication of two elements, or the interaction relationship between two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific implementation situation.
[0091] In the present application, unless otherwise specifically provided and limited, the first feature "on" or "under" the second feature can be that the first and second features are in direct contact, or the first and second features are indirectly in contact through an intermediate medium. Moreover, the first feature "above", "above" and "above" the second feature can be that the first feature is directly above or obliquely above the second feature, or only indicates that the horizontal height of the first feature is higher than that of the second feature. The first feature "below", "below" and "below" the second feature can be that the first feature is directly below or obliquely below the second feature, or only indicates that the horizontal height of the first feature is less than that of the second feature.
[0092] Although the embodiments of the present application have been shown and described above, it is understood that the above-described embodiments are exemplary and are not to be construed as limiting the present application, and that variations, modifications, substitutions and changes can be made by those skilled in the art without departing from the scope of the present application.
Claims
1. A task scheduling method, characterized by, The method is applied to a task scheduling system capable of communicating with a cache database, the cache database comprising at least a notification queue, a waiting queue, a working queue, a timeout queue, a frame sequence number cache and a delivery data cache, and the method comprises: In the case of listening to the to-be-processed task data in the message middleware component, the to-be-processed task data is parsed to obtain the identification of the collection terminal, the task identification and the task priority for processing the task, wherein the to-be-processed task data in the message middleware component is pushed by a business service system; The identification of the collection terminal is sent to the notification queue, and the to-be-processed task data and the task priority are sent to the waiting queue; In the case of listening to the identification of the collection terminal in the notification queue, the cache database is notified to execute a delivery script, wherein the delivery script is executed to 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 in the case that the number of tasks does not exceed a quantity threshold, the target task data corresponding to the collection terminal with the highest priority is obtained from the waiting queue, and the task identification corresponding to the target task data is written into the working queue; After the cache database is notified to execute the delivery script, the target task data is stored as delivery task data in the delivery data cache area in the cache database; After the delivery script is executed, the target task data corresponding to the task identification in the working queue is processed to obtain delivery protocol message data, including: after the delivery script is executed, if the target task data returned from the cache database is received, the frame sequence number that the collection terminal can parse is generated based on the identification of the collection terminal; the target task data and the frame sequence number are protocol-converted to obtain the delivery protocol message data; wherein the frame sequence number is used to match the task execution result, the task execution result is the result obtained by the collection terminal based on the delivery protocol message data for task processing, and the collection terminal returns the task execution result and the frame sequence number to the task scheduling system, so that the task scheduling system determines the corresponding task identification based on the frame sequence number; The delivery protocol message data is sent to the collection terminal, so that the collection terminal performs task processing based on the delivery protocol message data to obtain a task execution result; After receiving the task execution result returned by the collection terminal, the frame sequence number is parsed from the task execution result; The delivery task data corresponding to the frame sequence number is obtained from the delivery data cache area; The delivery task data corresponding to the frame sequence number in the delivery data cache area is parsed to obtain uplink normal message data and task identification; The uplink normal message data, the task identification and the task execution result are pushed to the business service system through the message middleware component.
2. The task scheduling method of claim 1, wherein, The cache database further comprises a timeout queue; by executing the delivery 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, a timeout time interval is parsed from the target task data, 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 of claim 1, wherein, The method further comprises: After obtaining the delivery task data corresponding to the frame sequence number from the delivery data cache area, the cache database is notified to execute a response script, wherein by executing the response script, the timeout time interval, the identifier of the collection terminal, and the task identifier corresponding to the parsed task identifier are deleted from the timeout queue, and the delivery task data corresponding to the parsed task identifier is deleted from the delivery data cache area; After pushing the uplink normal message data, the task identifier, and the task execution result to the business service system through the message middleware component, an instruction to process the next task is sent to the notification queue.
4. The task scheduling method according to claim 1, 2 or 3, characterized in that, The method further comprises: The cache database is notified to execute a timeout script, wherein by executing the timeout script, the target task data that is timed out is determined based on the timeout time interval in the timeout queue; the identifier of the collection terminal and the task identifier corresponding to the target task data that is timed out are obtained, and the target task data that is timed out is deleted from the timeout queue; the task identifier in the work queue is deleted based on the task identifier corresponding to the target task data that is timed out; The uplink timeout message is obtained based on the identifier of the collection terminal, the task identifier, and the timeout information corresponding to the target task data that is timed out; 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.
5. The task scheduling method of claim 1, 2, or 3, wherein, The task scheduling system comprises a plurality of service nodes capable of concurrent task scheduling; each collection terminal can execute a plurality of tasks at the same time.
6. The task scheduling method according to claim 1, wherein: The delivery protocol message data is sent to the collection terminal, comprising that the task scheduling system sends the delivery protocol message data to a front-end gateway, so that the front-end gateway sends the delivery protocol message data to the collection terminal; The task execution result returned by the collection terminal is received, comprising that 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 is from the collection terminal.
7. A task scheduling apparatus characterized by comprising: The task scheduling device is used to execute the method according to any one of claims 1-6, and the task scheduling device comprises: A listening and parsing module is configured to parse the to-be-processed task data in the message middleware component to obtain the identifier of the collection terminal, the task identifier, and the task priority for task processing, when the to-be-processed task data in the message middleware component is detected, wherein the to-be-processed task data in the message middleware component is pushed by the business service system. The sending module is configured to send the identifier of the collection terminal to a notification queue and send the to-be-processed task data and the task priority to a waiting queue; The notification execution module is configured to notify a cache database to execute a delivery script when the identifier of the collection terminal in the notification queue is listened to, and the delivery script is executed to achieve the following: querying the number of tasks currently executed by the collection terminal in the working queue based on the identifier of the collection terminal, and in a case where the number of tasks does not exceed a quantity threshold, obtaining target task data corresponding to the collection terminal with the highest priority from the waiting queue, and writing a task identifier corresponding to the target task data into the working queue; The message obtaining and sending module is configured to, after the delivery script is executed, process the target task data corresponding to the task identifier in the working queue to obtain delivery protocol message data, and send the delivery protocol message data to the collection terminal, so that the collection terminal processes the task based on the delivery protocol message data to obtain a task execution result. 8.An electronic device comprising a memory and a processor, the memory storing a computer program, wherein, The processor executes the computer program to implement the steps of the method in any one of claims 1-6.
9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1-6.
Citation Information
Patent Citations
Cross-platform distributed task scheduling system and scheduling method
CN113157420A
Method and equipment for realizing remote data acquisition
CN113961367A