Scheduled task scheduling execution method, device, electronic device and storage medium

Through the combination of remote dictionary services and distributed locks, the problem of traditional timed task scheduling relying on database is solved, efficient timed task execution is achieved, and work efficiency is improved.

CN112860394BActive Publication Date: 2024-11-22PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110083321.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-21
Publication Date
2024-11-22
Estimated Expiration
2041-01-21

AI Technical Summary

Technical Problem

The traditional timed task scheduling execution method relies on databases, which are inefficient and cannot be applied to microservices that do not rely on databases, resulting in problems of database dependency and scheduling efficiency.

Method used

Remote dictionary services are used to generate and save timing tasks, and target application services are determined using preset listeners and distributed locks to avoid dependence on the database and ensure efficient execution of timing tasks.

Benefits of technology

Through the combination of remote dictionary services and distributed locks, efficient scheduling and execution of timing tasks is achieved, database dependence is avoided, and work efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112860394B_ABST
    Figure CN112860394B_ABST
Patent Text Reader

Abstract

The present invention relates to big data technology, and discloses a method for scheduling and executing a scheduled task, including: receiving a scheduled task request, generating a scheduled task corresponding to the scheduled task request based on a remote dictionary service; saving the parameters of the scheduled task in the remote dictionary service according to the scheduled task request; determining a target application service based on a preset listener and a distributed lock; and executing the scheduled task using the target application service and the parameters. In addition, the present invention also relates to blockchain technology, and the scheduled task can be stored in a node of a blockchain. The present invention also proposes a scheduled task scheduling and execution device, an electronic device, and a computer-readable storage medium. The present invention can solve the problems of dependence on a database and low scheduling efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer data processing, and in particular to a method, device, electronic device and computer-readable storage medium for scheduling and executing a timed task. Background Art

[0002] With the explosive growth of data and business volume, a single server can no longer meet the needs. Most of the current business systems are deployed in a cluster manner. Scheduled tasks are very common in business systems, and the scheduling of scheduled tasks also plays an important role in business systems.

[0003] The traditional way to schedule scheduled tasks is to use Quartz, but this method relies on the database and requires the creation of several tables. It is inefficient and cannot be applied to microservices that do not rely on the database. Summary of the invention

[0004] The present invention provides a method and device for scheduling and executing a timed task, and a computer-readable storage medium, the main purpose of which is to solve the problems of dependence on a database and low scheduling efficiency.

[0005] To achieve the above object, the present invention provides a method for scheduling and executing a scheduled task, comprising:

[0006] Receiving a scheduled task request, and generating a scheduled task corresponding to the scheduled task request based on a remote dictionary service;

[0007] Saving parameters of the scheduled task in the remote dictionary service according to the scheduled task request;

[0008] Determine the target application service based on the preset listener and distributed lock;

[0009] The scheduled task is executed using the target application service and the parameters.

[0010] Optionally, the generating a scheduled task corresponding to the scheduled task request based on a remote dictionary service includes:

[0011] The type and the universal unique identifier in the scheduled task request are combined according to a preset format to generate a primary key;

[0012] Determine the expiration time by using the specific parameters in the scheduled task request;

[0013] A timed task corresponding to the primary key and the expiration time is generated in the remote dictionary service.

[0014] Optionally, obtaining the expiration time by performing time calculation on specific parameters in the scheduled task request includes:

[0015] Obtaining the scheduled task execution time from the specific parameters of the scheduled task request;

[0016] Get the current time;

[0017] The time interval between the scheduled task execution time and the current time is calculated to obtain an expiration time.

[0018] Optionally, the saving the parameters of the scheduled task in the remote dictionary service according to the scheduled task request includes:

[0019] Add a preset suffix to generate a parameter primary key after the primary key generation parameter of the scheduled task;

[0020] Obtaining specific parameters in the scheduled task request;

[0021] The specific parameters are written into the remote dictionary service as values ​​corresponding to the parameter primary key.

[0022] Optionally, the executing the scheduled task by using the target application service and the parameter includes:

[0023] Concatenate the primary key of the scheduled task with the preset suffix to obtain the corresponding parameter primary key;

[0024] Searching the remote dictionary service for the parameter of the scheduled task corresponding to the parameter primary key;

[0025] The scheduled task is executed in the target application service using the parameters.

[0026] Optionally, determining the target application service based on a preset listener and a distributed lock includes:

[0027] Determine whether the expiration time of the scheduled task has arrived;

[0028] When the expiration time arrives, using a preset listener to determine a plurality of application services that have received the message;

[0029] According to a preset command, an application service for acquiring a distributed lock is determined from the multiple application services to obtain a target application service.

[0030] Optionally, the determining, according to a preset command, from the multiple application services an application service for acquiring a distributed lock to obtain a target application service includes:

[0031] Execute the preset command in the multiple application services according to the primary key of the scheduled task to obtain multiple execution results;

[0032] An application service corresponding to a successful execution result among the multiple execution results is obtained, and it is determined that the application service has acquired a distributed lock, and a target application service is obtained.

[0033] In order to solve the above problem, the present invention further provides a timed task scheduling execution device, the device comprising:

[0034] A task generation module, used for receiving a scheduled task request and generating a scheduled task corresponding to the scheduled task request based on a remote dictionary service;

[0035] A parameter saving module, used for saving the parameters of the scheduled task in the remote dictionary service according to the scheduled task request;

[0036] A service determination module, used to determine the target application service based on a preset listener and distributed lock;

[0037] The task execution module is used to execute the scheduled task using the target application service and the parameters.

[0038] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:

[0039] a memory storing at least one instruction; and

[0040] The processor executes the instructions stored in the memory to implement the above-mentioned scheduled task scheduling execution method.

[0041] In order to solve the above problem, the present invention also provides a computer-readable storage medium, in which at least one instruction is stored. The at least one instruction is executed by a processor in an electronic device to implement the above-mentioned scheduled task scheduling execution method.

[0042] The embodiment of the present invention receives a scheduled task request, generates a scheduled task corresponding to the scheduled task request based on a remote dictionary service, and uses the remote dictionary service to write the parameters of the scheduled task into the content, thereby avoiding dependence on the database; determines the target application service based on a preset listener and a distributed lock, and can quickly obtain the scheduled task through the listener, and can schedule the scheduled task using a preset command as a distributed lock, thereby avoiding repeated execution of the scheduled task by multiple application services, thereby improving the efficiency of task scheduling; and uses the target application service to execute the scheduled task, thereby ensuring the execution of the scheduled task and improving work efficiency. Therefore, the scheduled task scheduling execution method, device, electronic device, and computer-readable storage medium proposed by the present invention can solve the problems of dependence on the database and low scheduling efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1A schematic diagram of a flow chart of a method for scheduling and executing a scheduled task provided by an embodiment of the present invention;

[0044] Figure 2 A functional module diagram of a timed task scheduling execution device provided by an embodiment of the present invention;

[0045] Figure 3 A schematic diagram of the structure of an electronic device for implementing the scheduled task scheduling execution method provided by an embodiment of the present invention.

[0046] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0047] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0048] The embodiment of the present application provides a method for scheduling and executing a scheduled task. The execution subject of the scheduled task scheduling execution method includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the scheduled task scheduling execution method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc.

[0049] Reference Figure 1 FIG. 1 is a flow chart of a method for scheduling and executing a scheduled task provided by an embodiment of the present invention. In this embodiment, the method for scheduling and executing a scheduled task includes:

[0050] S1. Receive a scheduled task request, and generate a scheduled task corresponding to the scheduled task request based on a remote dictionary service.

[0051] The scheduled task request in the embodiment of the present invention is an HTTP protocol request sent by the client, and the scheduled task request includes a type, a universal unique identifier (uuid) and specific parameters.

[0052] Furthermore, the embodiment of the present invention processes the scheduled task based on a remote dictionary server (redis) to obtain a scheduled task corresponding to the scheduled task request. The redis is an open source, ANSI C language-written, network-supporting, memory-based, and persistent log-type, Key-Value database, and provides APIs in multiple languages. The redis can directly store data in memory instead of in a database, thereby avoiding dependence on a database.

[0053] In detail, the generating of the scheduled task corresponding to the scheduled task request based on the remote dictionary service includes:

[0054] The type and the universal unique identifier in the scheduled task request are combined according to a preset format to generate a primary key;

[0055] The expiration time is obtained by calculating the time of the specific parameters in the scheduled task request;

[0056] A timed task corresponding to the primary key and the expiration time is generated in the remote dictionary service.

[0057] The embodiment of the present invention can generate a scheduled task corresponding to the scheduled task request in the remote dictionary service after receiving the scheduled task request.

[0058] For example, the type in the scheduled task request is tel, tel represents a telephone reminder task, the uuid is 998009e5bb1d291a16ec97b3ee8d870, and the primary key is the type plus uuid, that is, tel_998009e5bb1d291a16ec97b3ee8d870, and the value corresponding to the primary key can be set at will. The primary key and the corresponding value are written into the remote dictionary service, and the expiration time is set according to the specific parameters in the scheduled task request, and a scheduled task can be obtained. After the expiration time is reached, the scheduled task will be deleted in the remote dictionary service.

[0059] To further ensure the privacy and security of the scheduled task, the scheduled task can also be stored in a node of a blockchain.

[0060] Further, the obtaining of the expiration time by performing time calculation on specific parameters in the scheduled task request includes:

[0061] Obtaining the scheduled task execution time from the specific parameters of the scheduled task request;

[0062] Get the current time;

[0063] The time interval between the scheduled task execution time and the current time is calculated to obtain an expiration time, and the expiration time is set in the remote dictionary service.

[0064] For example, if the scheduled task execution time is 2020-11-30 18:00 and the current time is 2020-11-30 17:00, set the expiration time to the scheduled task execution time - current time, which is 3600 (the default unit is seconds).

[0065] S2. Save the parameters of the scheduled task in the remote dictionary service according to the scheduled task request.

[0066] In detail, the storing the parameters of the scheduled task in the remote dictionary service according to the scheduled task request includes:

[0067] Add a preset suffix to generate a parameter primary key after the primary key generation parameter of the scheduled task;

[0068] Obtaining specific parameters in the scheduled task request;

[0069] The specific parameters are written into the remote dictionary service as values ​​corresponding to the parameter primary key.

[0070] Furthermore, the parameter primary key corresponds to the primary key of the scheduled task, and the parameter primary key can be generated by adding a preset suffix to the primary key of the scheduled task. For example, if the primary key of the scheduled task is tel_998009e5bb1d291a16ec97b3ee8d870, then the parameter primary key is tel_998009e5bb1d291a16ec97b3ee8d870_params.

[0071] The specific parameters are specific parameters required to execute the scheduled task, for example, tel=123456, content=3pm meeting, that is, the scheduled task is specifically to dial 123456 for reminder, and the content is the 3pm meeting.

[0072] S3. Determine the target application service based on the preset listener and distributed lock.

[0073] Before determining the target application service based on the preset listener and the distributed lock, the embodiment of the present invention further includes: enabling an expiration monitoring function in the preset multiple application services.

[0074] Furthermore, the expiration monitoring function is to enable a monitoring event in each application service. After the expiration time of the scheduled task arrives, since the application service has set the monitoring event in advance, the listener can capture the corresponding monitoring event and send a message to multiple application services, and the message includes the primary key of the scheduled task corresponding to the expiration time.

[0075] In detail, the determining of the target application service based on the preset listener and the distributed lock includes:

[0076] Determine whether the expiration time of the scheduled task has arrived;

[0077] When the expiration time arrives, using a preset listener to determine a plurality of application services that have received the message;

[0078] According to a preset command, an application service for acquiring a distributed lock is determined from the multiple application services to obtain a target application service.

[0079] Further, the step of determining the application service for acquiring the distributed lock according to the preset command to obtain the target application service includes:

[0080] Execute the preset command in the multiple application services according to the primary key of the scheduled task to obtain multiple execution results;

[0081] An application service corresponding to a successful execution result among the multiple execution results is obtained, and it is determined that the application service has acquired a distributed lock, and a target application service is obtained.

[0082] The preset command may be a setnx command, which takes a primary key as a parameter. Only when the primary key does not exist, the value corresponding to the primary key is set, and the corresponding execution result is success; when the primary key exists, no action is taken, and the corresponding execution result is failure. When multiple application services execute the setnx command at the same time, if one application service is executed successfully, the other application services will fail to execute.

[0083] S4. Execute the scheduled task using the target application service and the parameters.

[0084] In detail, the using the target application service and the parameters to execute the scheduled task includes:

[0085] Concatenate the primary key of the scheduled task with the preset suffix to obtain the corresponding parameter primary key;

[0086] Searching the remote dictionary service for the parameter of the scheduled task corresponding to the parameter primary key;

[0087] The scheduled task is executed in the target application service using the parameters.

[0088] For example, after determining that the target application service is an outbound call service platform, the corresponding parameter primary key can be obtained by adding a preset suffix to the primary key of the scheduled task. Then, the value corresponding to the parameter primary key is obtained from the remote dictionary service to obtain the specific parameters of the scheduled task, such as tel=123456, content=3pm meeting. The outbound call service platform starts to execute the scheduled task, that is, dial 123456 for reminder, and the reminder content is the 3pm meeting.

[0089] Optionally, if the scheduled task fails to execute, a re-execution time may be determined according to the scheduled task; the scheduled task may be regenerated according to the re-execution time, and the scheduled task may be re-executed.

[0090] In the embodiment of the present invention, the parameters of the scheduled task are saved and can be queried as a historical record of the scheduled task.

[0091] The embodiment of the present invention receives a scheduled task request, generates a scheduled task corresponding to the scheduled task request based on a remote dictionary service, and uses the remote dictionary service to write the parameters of the scheduled task into the content, thereby avoiding dependence on the database; determines the target application service based on a preset listener and a distributed lock, and can quickly obtain the scheduled task through the listener, and can schedule the scheduled task using a preset command as a distributed lock, thereby avoiding repeated execution of the scheduled task by multiple application services, thereby improving the efficiency of task scheduling; and uses the target application service to execute the scheduled task, thereby ensuring the execution of the scheduled task and improving work efficiency. Therefore, the scheduled task scheduling execution method, device, electronic device, and computer-readable storage medium proposed by the present invention can solve the problems of dependence on the database and low scheduling efficiency.

[0092] like Figure 2 , which is a functional module diagram of a timed task scheduling execution device provided by an embodiment of the present invention.

[0093] The scheduled task scheduling execution device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the scheduled task scheduling execution device 100 may include a task generation module 101, a parameter storage module 102, a service determination module 103 and a task execution module 104. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.

[0094] In this embodiment, the functions of each module / unit are as follows:

[0095] The task generation module 101 is used to receive a scheduled task request and generate a scheduled task corresponding to the scheduled task request based on a remote dictionary service.

[0096] The scheduled task request in the embodiment of the present invention is an HTTP protocol request sent by the client, and the scheduled task request includes a type, a universal unique identifier (uuid) and specific parameters.

[0097] Furthermore, the embodiment of the present invention processes the scheduled task based on a remote dictionary server (redis) to obtain a scheduled task corresponding to the scheduled task request. The redis is an open source, ANSI C language-written, network-supporting, memory-based, and persistent log-type, Key-Value database, and provides APIs in multiple languages. The redis can directly store data in memory instead of in a database, thereby avoiding dependence on a database.

[0098] In detail, when generating a scheduled task corresponding to the scheduled task request based on the remote dictionary service, the task generation module 101 specifically performs the following operations:

[0099] The type and the universal unique identifier in the scheduled task request are combined according to a preset format to generate a primary key;

[0100] The expiration time is obtained by calculating the time of the specific parameters in the scheduled task request;

[0101] A timed task corresponding to the primary key and the expiration time is generated in the remote dictionary service.

[0102] The embodiment of the present invention can generate a scheduled task corresponding to the scheduled task request in the remote dictionary service after receiving the scheduled task request.

[0103] For example, the type in the scheduled task request is tel, tel represents a telephone reminder task, the uuid is 998009e5bb1d291a16ec97b3ee8d870, and the primary key is the type plus uuid, that is, tel_998009e5bb1d291a16ec97b3ee8d870, and the value corresponding to the primary key can be set at will. The primary key and the corresponding value are written into the remote dictionary service, and the expiration time is set according to the specific parameters in the scheduled task request, and a scheduled task can be obtained. After the expiration time is reached, the scheduled task will be deleted in the remote dictionary service.

[0104] To further ensure the privacy and security of the scheduled task, the scheduled task can also be stored in a node of a blockchain.

[0105] Further, the obtaining of the expiration time by performing time calculation on specific parameters in the scheduled task request includes:

[0106] Obtaining the scheduled task execution time from the specific parameters of the scheduled task request;

[0107] Get the current time;

[0108] The time interval between the scheduled task execution time and the current time is calculated to obtain an expiration time, and the expiration time is set in the remote dictionary service.

[0109] For example, if the scheduled task execution time is 2020-11-30 18:00 and the current time is 2020-11-30 17:00, set the expiration time to the scheduled task execution time - current time, which is 3600 (the default unit is seconds).

[0110] The parameter saving module 102 is used to save the parameters of the scheduled task in the remote dictionary service according to the scheduled task request.

[0111] In detail, the parameter saving module 102 is specifically used for:

[0112] Add a preset suffix to generate a parameter primary key after the primary key generation parameter of the scheduled task;

[0113] Obtaining specific parameters in the scheduled task request;

[0114] The specific parameters are written into the remote dictionary service as values ​​corresponding to the parameter primary key.

[0115] Furthermore, the parameter primary key corresponds to the primary key of the scheduled task, and the parameter primary key can be generated by adding a preset suffix to the primary key of the scheduled task. For example, if the primary key of the scheduled task is tel_998009e5bb1d291a16ec97b3ee8d870, then the parameter primary key is tel_998009e5bb1d291a16ec97b3ee8d870_params.

[0116] The specific parameters are specific parameters required to execute the scheduled task, for example, tel=123456, content=3pm meeting, that is, the scheduled task is specifically to dial 123456 for reminder, and the content is the 3pm meeting.

[0117] The service determination module 103 is used to determine the target application service based on the preset listener and distributed lock.

[0118] Before determining the target application service based on the preset listener and the distributed lock, the embodiment of the present invention further includes: enabling an expiration monitoring function in the preset multiple application services.

[0119] Furthermore, the expiration monitoring function is to enable a monitoring event in each application service. After the expiration time of the scheduled task arrives, since the application service has set the monitoring event in advance, the listener can capture the corresponding monitoring event and send a message to multiple application services, and the message includes the primary key of the scheduled task corresponding to the expiration time.

[0120] In detail, the service determination module 103 is specifically used for:

[0121] Determine whether the expiration time of the scheduled task has arrived;

[0122] When the expiration time arrives, using a preset listener to determine a plurality of application services that have received the message;

[0123] According to a preset command, an application service for acquiring a distributed lock is determined from the multiple application services to obtain a target application service.

[0124] Further, the step of determining the application service for acquiring the distributed lock according to the preset command to obtain the target application service includes:

[0125] Execute the preset command in the multiple application services according to the primary key of the scheduled task to obtain multiple execution results;

[0126] An application service corresponding to a successful execution result among the multiple execution results is obtained, and it is determined that the application service has acquired a distributed lock, and a target application service is obtained.

[0127] The preset command may be a setnx command, which takes a primary key as a parameter. Only when the primary key does not exist, the value corresponding to the primary key is set, and the corresponding execution result is success; when the primary key exists, no action is taken, and the corresponding execution result is failure. When multiple application services execute the setnx command at the same time, if one application service is executed successfully, the other application services will fail to execute.

[0128] The task execution module 104 is used to execute the scheduled task using the target application service and the parameters.

[0129] In detail, the task execution module 104 is specifically used for:

[0130] Concatenate the primary key of the scheduled task with the preset suffix to obtain the corresponding parameter primary key;

[0131] Searching the remote dictionary service for the parameter of the scheduled task corresponding to the parameter primary key;

[0132] The scheduled task is executed in the target application service using the parameters.

[0133] For example, after determining that the target application service is an outbound call service platform, the corresponding parameter primary key can be obtained by adding a preset suffix to the primary key of the scheduled task. Then, the value corresponding to the parameter primary key is obtained from the remote dictionary service to obtain the specific parameters of the scheduled task, such as tel=123456, content=3pm meeting. The outbound call service platform starts to execute the scheduled task, that is, dial 123456 for reminder, and the reminder content is the 3pm meeting.

[0134] Optionally, if the scheduled task fails to execute, a re-execution time may be determined according to the scheduled task; the scheduled task may be regenerated according to the re-execution time, and the scheduled task may be re-executed.

[0135] In the embodiment of the present invention, the parameters of the scheduled task are saved and can be queried as a historical record of the scheduled task.

[0136] like Figure 3 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing a method for scheduling and executing a scheduled task provided by an embodiment of the present invention.

[0137] The electronic device 1 may include a processor 10 , a memory 11 and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10 , such as a scheduled task scheduling execution program 12 .

[0138] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of the electronic device 1, such as a mobile hard disk of the electronic device 1. In other embodiments, the memory 11 may also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 11 may also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device 1, such as the code of the scheduled task scheduling execution program 12, etc., but may also be used to temporarily store data that has been output or is to be output.

[0139] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes various functions and processes data of the electronic device 1 by running or executing programs or modules (such as scheduled task scheduling execution programs, etc.) stored in the memory 11, and calling data stored in the memory 11.

[0140] The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.

[0141] Figure 3 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.

[0142] For example, although not shown, the electronic device 1 may also include a power source (such as a battery) for supplying power to various components. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.

[0143] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device 1 and other electronic devices.

[0144] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.

[0145] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0146] The scheduled task scheduling execution program 12 stored in the memory 11 in the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:

[0147] Receiving a scheduled task request, and generating a scheduled task corresponding to the scheduled task request based on a remote dictionary service;

[0148] Saving parameters of the scheduled task in the remote dictionary service according to the scheduled task request;

[0149] Determine the target application service based on the preset listener and distributed lock;

[0150] The scheduled task is executed using the target application service and the parameters.

[0151] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to Figures 1 to 3 The description of the relevant steps in the corresponding embodiments will not be repeated here.

[0152] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).

[0153] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:

[0154] Receiving a scheduled task request, and generating a scheduled task corresponding to the scheduled task request based on a remote dictionary service;

[0155] Saving parameters of the scheduled task in the remote dictionary service according to the scheduled task request;

[0156] Determine the target application service based on the preset listener and distributed lock;

[0157] The scheduled task is executed using the target application service and the parameters.

[0158] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.

[0159] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0160] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0161] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0162] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.

[0163] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0164] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.

[0165] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.

Claims

1. A method for scheduling and executing a scheduled task. It is characterized in that The method comprises: Receiving a scheduled task request, and generating a scheduled task corresponding to the scheduled task request based on a remote dictionary service; Saving parameters of the scheduled task in the remote dictionary service according to the scheduled task request; Determine the target application service based on the preset listener and distributed lock; Executing the scheduled task using the target application service and the parameters; The generating of the scheduled task corresponding to the scheduled task request based on the remote dictionary service includes: merging the type and the universal unique identification code in the scheduled task request to generate a primary key according to a preset format; obtaining an expiration time by performing time calculation on specific parameters in the scheduled task request; generating a scheduled task corresponding to the primary key and the expiration time in the remote dictionary service; The method of saving the parameters of the scheduled task in the remote dictionary service according to the scheduled task request includes: adding a preset suffix after the primary key generation parameter of the scheduled task to generate a parameter primary key; obtaining specific parameters in the scheduled task request; and writing the specific parameters into the remote dictionary service as values ​​corresponding to the parameter primary key.

2. The method for scheduling and executing a scheduled task according to claim 1, It is characterized in that The obtaining of the expiration time by performing time calculation on specific parameters in the scheduled task request includes: Obtaining the scheduled task execution time from the specific parameters of the scheduled task request; Get the current time; The time interval between the scheduled task execution time and the current time is calculated to obtain an expiration time.

3. The method for scheduling and executing a scheduled task according to claim 1, It is characterized in that The using the target application service and the parameters to execute the scheduled task includes: Concatenate the primary key of the scheduled task with the preset suffix to obtain the corresponding parameter primary key; Searching the remote dictionary service for the parameter of the scheduled task corresponding to the parameter primary key; The scheduled task is executed in the target application service using the parameters.

4. The method for scheduling and executing a scheduled task according to claim 1, It is characterized in that The determining of the target application service based on the preset listener and the distributed lock includes: Determine whether the expiration time of the scheduled task has arrived; When the expiration time arrives, using a preset listener to determine a plurality of application services that have received the message; According to a preset command, an application service for acquiring a distributed lock is determined from the multiple application services to obtain a target application service.

5. The method for scheduling and executing scheduled tasks as claimed in claim 4, It is characterized in that The step of determining the application service for acquiring the distributed lock from the plurality of application services according to the preset command to obtain the target application service includes: Execute the preset command in the multiple application services according to the primary key of the scheduled task to obtain multiple execution results; An application service corresponding to a successful execution result among the multiple execution results is obtained, and it is determined that the application service has acquired a distributed lock, and a target application service is obtained.

6. A timed task scheduling execution device, used to implement the timed task scheduling execution method as claimed in any one of claims 1 to 5, It is characterized in that The device comprises: A task generation module, used for receiving a scheduled task request and generating a scheduled task corresponding to the scheduled task request based on a remote dictionary service; A parameter saving module, used for saving the parameters of the scheduled task in the remote dictionary service according to the scheduled task request; A service determination module, used to determine the target application service based on a preset listener and distributed lock; The task execution module is used to execute the scheduled task using the target application service and the parameters.

7. An electronic device, It is characterized in that The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the scheduled task scheduling execution method as described in any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, the scheduled task scheduling execution method as described in any one of claims 1 to 5 is implemented.