CN112860394A - Timing task scheduling execution method and device, electronic equipment and storage medium - Google Patents

Timing task scheduling execution method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112860394A
CN112860394A CN202110083321.2A CN202110083321A CN112860394A CN 112860394 A CN112860394 A CN 112860394A CN 202110083321 A CN202110083321 A CN 202110083321A CN 112860394 A CN112860394 A CN 112860394A
Authority
CN
China
Prior art keywords
timing task
task
timing
service
application service
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110083321.2A
Other languages
Chinese (zh)
Inventor
周崧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202110083321.2A priority Critical patent/CN112860394A/en
Publication of CN112860394A publication Critical patent/CN112860394A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to big data technology, and discloses a timing task scheduling execution method, which comprises the following steps: receiving a timing task request, and generating a timing task corresponding to the timing task request based on a remote dictionary service; storing the parameters of the timing task in the remote dictionary service according to the timing task request; determining a target application service based on a preset listener and a distributed lock; executing the timed task using the target application service and the parameters. Furthermore, the invention relates to a blockchain technique, the timing tasks being storable in nodes of the blockchain. The invention also provides a timing task scheduling execution device, electronic equipment and a computer readable storage medium. The invention can solve the problems of low dependency on the database and low scheduling efficiency.

Description

Timing task scheduling execution method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of big data, in particular to a method and a device for scheduling and executing a timing task, electronic equipment and a computer readable storage medium.
Background
With the explosive growth of data and service volume, a single server cannot meet the requirement, most of the existing service systems are deployed in a cluster mode, timing tasks are very common in the service systems, and the scheduling processing of the timing tasks plays an important role in the service systems.
The traditional execution mode of timing task scheduling uses Quartz (extended-tesz formula), but the mode depends on a database, needs to create a plurality of tables, is low in efficiency, and cannot be applied to database-independent microservice.
Disclosure of Invention
The invention provides a method and a device for scheduling and executing a timing task and a computer readable storage medium, and mainly aims to solve the problems of dependency on a database and low scheduling efficiency.
In order to achieve the above object, a method for scheduling and executing a timed task provided by the present invention includes:
receiving a timing task request, and generating a timing task corresponding to the timing task request based on a remote dictionary service;
storing the parameters of the timing task in the remote dictionary service according to the timing task request;
determining a target application service based on a preset listener and a distributed lock;
executing the timed task using the target application service and the parameters.
Optionally, the generating a timing task corresponding to the timing task request based on the remote dictionary service includes:
combining the type and the universal unique identification code in the timing task request according to a preset format to generate a main key;
determining an expiration time according to specific parameters in the timed task request;
generating a timing task in the remote dictionary service corresponding to the primary key and the expiration time.
Optionally, the obtaining of the expiration time by performing time calculation on specific parameters in the timed task request includes:
acquiring the execution time of the timing task from the specific parameters of the timing task request;
acquiring current time;
and calculating the time interval between the execution time of the timing task and the current time to obtain the expiration time.
Optionally, the storing the parameter of the timing task in the remote dictionary service according to the timing task request includes:
adding a preset suffix to generate a parameter primary key after the primary key of the timing task generates a parameter;
acquiring specific parameters in the timing task request;
and writing the specific parameters into the remote dictionary service together as the values corresponding to the parameter primary keys.
Optionally, the executing the timing task by using the target application service and the parameter includes:
splicing the primary key of the timing task with a preset suffix to obtain a corresponding parameter primary key;
searching the parameter of the timing task corresponding to the parameter main key from the remote dictionary service;
and executing the timing task in the target application service by using the parameters.
Optionally, the determining a target application service based on the preset listener and the distributed lock includes:
judging whether the expiration time of the timing task is reached;
when the expiration time is reached, determining a plurality of application services of the received message by using a preset listener;
and determining to acquire the application service of the distributed lock from the plurality of application services according to a preset command to obtain a target application service.
Optionally, the determining, according to a preset command, an application service for acquiring a distributed lock from the plurality of application services to obtain a target application service includes:
executing the preset command in the plurality of application services according to the main key of the timing task to obtain a plurality of execution results;
and acquiring the application service corresponding to the successful execution result in the execution results, and judging that the application service acquires the distributed lock to obtain the target application service.
In order to solve the above problem, the present invention further provides a device for scheduling and executing a timed task, including:
the task generation module is used for receiving a timing task request and generating a timing task corresponding to the timing task request based on a remote dictionary service;
the parameter storage module is used for storing the parameters of the timing task in the remote dictionary service according to the timing task request;
the service determining module is used for determining target application service based on a preset monitor and a distributed lock;
and the task execution module is used for executing the timing task by using the target application service and the parameters.
In order to solve the above problem, the present invention also provides an electronic device, including:
a memory storing at least one instruction; and
and the processor executes the instructions stored in the memory to realize the timing task scheduling execution method.
In order to solve the above problem, the present invention further provides a computer-readable storage medium, which stores at least one instruction, where the at least one instruction is executed by a processor in an electronic device to implement the above method for scheduling and executing a timed task.
The embodiment of the invention receives the timing task request, generates the timing task corresponding to the timing task request based on the remote dictionary service, and can write the parameters of the timing task into the content by utilizing the remote dictionary service, thereby avoiding the dependency on the database; the target application service is determined based on the preset monitor and the distributed lock, the timed task can be quickly obtained through the monitor, meanwhile, the timed task can be scheduled by using the preset command as the distributed lock, the timed task is prevented from being repeatedly executed by a plurality of application services, and the task scheduling efficiency is improved; and the timing task is executed by utilizing the target application service, so that the execution of the timing task is ensured, and the working efficiency is improved. Therefore, the timing task scheduling execution method, the timing task scheduling execution device, the electronic equipment and the computer readable storage medium can solve the problems of dependency on a database and low scheduling efficiency.
Drawings
Fig. 1 is a flowchart illustrating a method for scheduling and executing a timed task according to an embodiment of the present invention;
FIG. 2 is a functional block diagram of a device for scheduling and executing a timed task according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device for implementing the method for scheduling and executing a timed task according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the application provides a timing task scheduling execution method. The execution subject of the timing task scheduling execution method includes, but is not limited to, at least one of electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiments of the present application. In other words, the timing task scheduling execution method may be executed by software or hardware installed in the terminal device or the server device, and the software may be a block chain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
Fig. 1 is a schematic flowchart of a method for scheduling and executing a timed task according to an embodiment of the present invention. In this embodiment, the method for scheduling and executing the timed task includes:
and S1, receiving the timing task request, and generating a timing task corresponding to the timing task request based on the remote dictionary service.
The timed task request in the embodiment of the invention is an HTTP (hyper text transport protocol) protocol request sent by a client, and the timed task request comprises a type, a universal unique identification code (uuid) and specific parameters.
Further, in the embodiment of the present invention, the timed task is processed based on a Remote Dictionary service (Remote Dictionary Server, redis), so as to obtain the timed task corresponding to the timed task request. The redis is an open source, is written by ANSIC language, supports network, can be based on a log-type and Key-Value database with memory and persistence, and provides API of multiple languages. The redis can directly store the data in the memory instead of the database, so that the dependence on the database can be avoided.
In detail, the generating a timing task corresponding to the timing task request based on a remote dictionary service includes:
combining the type and the universal unique identification code in the timing task request according to a preset format to generate a main key;
obtaining the expiration time by carrying out time calculation on specific parameters in the timing task request;
generating a timing task in the remote dictionary service corresponding to the primary key and the expiration time.
The embodiment of the invention can generate a timing task corresponding to the timing task request in the remote dictionary service after receiving the timing task request.
For example, the type of the timed task request is tel, the tel represents a phone call reminding task, the uuid is 998009e5bb1d291a16ec97b3ee8d870, the primary key is the type plus the uuid, that is, tel — 998009e5bb1d291a16ec97b3ee8d870, and the value (value) corresponding to the primary key can be set optionally, 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 timed task request, so that a timed task can be obtained, and the timed task is deleted in the remote dictionary service after the expiration time is reached.
To further ensure privacy and security of the timing task, the timing task may also be stored in a node of a block chain.
Further, the obtaining of the expiration time by performing time calculation on specific parameters in the timed task request includes:
acquiring the execution time of the timing task from the specific parameters of the timing task request;
acquiring current time;
and calculating the time interval between the timing task execution time and the current time to obtain the expiration time, and setting the expiration time in the remote dictionary service.
For example, the timed task execution time is 2020-11-3018: 00, the current time is 2020-11-3017:00, and the expiration time is set to the timed task execution time-current time, i.e., 3600 (units default to seconds).
S2, storing the parameters of the timing task in the remote dictionary service according to the timing task request.
In detail, the saving the parameter of the timing task in the remote dictionary service according to the timing task request includes:
adding a preset suffix to generate a parameter primary key after the primary key of the timing task generates a parameter;
acquiring specific parameters in the timing task request;
and writing the specific parameters into the remote dictionary service together as values corresponding to the parameter primary keys.
Further, the parameter primary key corresponds to a primary key of the timed task, and a preset suffix is added after the primary key of the timed task to generate the parameter primary key, for example, if the primary key of the timed task is tel _998009e5bb1d291a16ec97b3ee8d870, the parameter primary key is tel _998009e5bb1d291a16ec97b3ee8d870_ params.
The specific parameter is a specific parameter required for executing the timing task, for example, tel is 123456, content is three-point afternoon meeting, that is, the timing task is specifically to call 123456 for reminding, and the content is three-point afternoon meeting.
And S3, determining the target application service based on the preset listener and the distributed lock.
Before determining the target application service based on the preset listener and the distributed lock, the embodiment of the invention further comprises: and starting the overdue monitoring function in a plurality of preset application services.
Further, the function of starting the overdue monitoring is to start monitoring events in each application service, and after the expiration time of the timing task is reached, since the application service sets the monitoring events in advance, the listener can capture the corresponding monitoring events and send messages to the plurality of application services, where the messages include the primary key of the timing task corresponding to the expiration time.
In detail, the determining a target application service based on the preset listener and the distributed lock includes:
judging whether the expiration time of the timing task is reached;
when the expiration time is reached, determining a plurality of application services of the received message by using a preset listener;
and determining to acquire the application service of the distributed lock from the plurality of application services according to a preset command to obtain a target application service.
Further, the determining to acquire the application service of the distributed lock according to the preset command to obtain the target application service includes:
executing the preset command in the plurality of application services according to the main key of the timing task to obtain a plurality of execution results;
and acquiring the application service corresponding to the successful execution result in the execution results, and judging that the application service acquires the distributed lock to obtain the target application service.
The preset command may be a setnx command, the setnx command takes a primary key (key) as a parameter, and only under the condition that the primary key does not exist, a value corresponding to the primary key is set, and a corresponding execution result is successful; when the main key exists, no action is performed, and the corresponding execution result is failure. When a plurality of application services execute the setnx command at the same time, after one application service is successfully executed, the other application services all fail to be executed.
S4, executing the timing task by using the target application service and the parameters.
In detail, the performing the timing task using the target application service and the parameter includes:
splicing the primary key of the timing task with a preset suffix to obtain a corresponding parameter primary key;
searching the parameter of the timing task corresponding to the parameter main key from the remote dictionary service;
and executing the timing task in the target application service by using the parameters.
For example, after the target application service is determined to be the outbound service platform, the corresponding parameter primary key can be obtained according to the primary key of the timing task plus a preset suffix. And then, obtaining a value corresponding to the parameter main key from the remote dictionary service, so as to obtain specific parameters of the timing task, such as tel 123456 and content three-point conference in the afternoon. The outbound service platform starts to execute a timing task, namely calls 123456 for reminding, and the reminding content is a three-point meeting in the afternoon.
Optionally, if the execution of the timing task fails, the re-execution time may be determined according to the timing task; and regenerating the timing task according to the re-execution time, and re-executing the timing task.
In the embodiment of the invention, the parameters of the timing task are stored and can be used as the historical record of the timing task for inquiring.
The embodiment of the invention receives the timing task request, generates the timing task corresponding to the timing task request based on the remote dictionary service, and can write the parameters of the timing task into the content by utilizing the remote dictionary service, thereby avoiding the dependency on the database; the target application service is determined based on the preset monitor and the distributed lock, the timed task can be quickly obtained through the monitor, meanwhile, the timed task can be scheduled by using the preset command as the distributed lock, the timed task is prevented from being repeatedly executed by a plurality of application services, and the task scheduling efficiency is improved; and the timing task is executed by utilizing the target application service, so that the execution of the timing task is ensured, and the working efficiency is improved. Therefore, the timing task scheduling execution method, the timing task scheduling execution device, the electronic equipment and the computer readable storage medium can solve the problems of dependency on a database and low scheduling efficiency.
Fig. 2 is a functional block diagram of a device for scheduling and executing a timed task according to an embodiment of the present invention.
The timing task scheduling executing apparatus 100 according to the present invention may be installed in an electronic device. According to the implemented functions, the timed task scheduling executing device 100 may include a task generating module 101, a parameter saving module 102, a service determining module 103, and a task executing module 104. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the task generating module 101 is configured to receive a timing task request, and generate a timing task corresponding to the timing task request based on a remote dictionary service.
The timed task request in the embodiment of the invention is an HTTP (hyper text transport protocol) protocol request sent by a client, and the timed task request comprises a type, a universal unique identification code (uuid) and specific parameters.
Further, in the embodiment of the present invention, the timed task is processed based on a Remote Dictionary service (Remote Dictionary Server, redis), so as to obtain the timed task corresponding to the timed task request. The redis is an open source, is written by ANSIC language, supports network, can be based on a log-type and Key-Value database with memory and persistence, and provides API of multiple languages. The redis can directly store the data in the memory instead of the database, so that the dependence on the database can be avoided.
In detail, when generating a timed task corresponding to the timed task request based on a remote dictionary service, the task generating module 101 specifically performs the following operations:
combining the type and the universal unique identification code in the timing task request according to a preset format to generate a main key;
obtaining the expiration time by carrying out time calculation on specific parameters in the timing task request;
generating a timing task in the remote dictionary service corresponding to the primary key and the expiration time.
The embodiment of the invention can generate a timing task corresponding to the timing task request in the remote dictionary service after receiving the timing task request.
For example, the type of the timed task request is tel, the tel represents a phone call reminding task, the uuid is 998009e5bb1d291a16ec97b3ee8d870, the primary key is the type plus the uuid, that is, tel — 998009e5bb1d291a16ec97b3ee8d870, and the value (value) corresponding to the primary key can be set optionally, 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 timed task request, so that a timed task can be obtained, and the timed task is deleted in the remote dictionary service after the expiration time is reached.
To further ensure privacy and security of the timing task, the timing task may also be stored in a node of a block chain.
Further, the obtaining of the expiration time by performing time calculation on specific parameters in the timed task request includes:
acquiring the execution time of the timing task from the specific parameters of the timing task request;
acquiring current time;
and calculating the time interval between the timing task execution time and the current time to obtain the expiration time, and setting the expiration time in the remote dictionary service.
For example, the timed task execution time is 2020-11-3018: 00, the current time is 2020-11-3017:00, and the expiration time is set to the timed task execution time-current time, i.e., 3600 (units default to seconds).
The parameter saving module 102 is configured to save the parameter of the timed task in the remote dictionary service according to the timed task request.
In detail, the parameter saving module 102 is specifically configured to:
adding a preset suffix to generate a parameter primary key after the primary key of the timing task generates a parameter;
acquiring specific parameters in the timing task request;
and writing the specific parameters into the remote dictionary service together as values corresponding to the parameter primary keys.
Further, the parameter primary key corresponds to a primary key of the timed task, and a preset suffix is added after the primary key of the timed task to generate the parameter primary key, for example, if the primary key of the timed task is tel _998009e5bb1d291a16ec97b3ee8d870, the parameter primary key is tel _998009e5bb1d291a16ec97b3ee8d870_ params.
The specific parameter is a specific parameter required for executing the timing task, for example, tel is 123456, content is three-point afternoon meeting, that is, the timing task is specifically to call 123456 for reminding, and the content is three-point afternoon meeting.
The service determination module 103 is configured to determine a target application service based on a preset listener and a distributed lock.
Before determining the target application service based on the preset listener and the distributed lock, the embodiment of the invention further comprises: and starting the overdue monitoring function in a plurality of preset application services.
Further, the function of starting the overdue monitoring is to start monitoring events in each application service, and after the expiration time of the timing task is reached, since the application service sets the monitoring events in advance, the listener can capture the corresponding monitoring events and send messages to the plurality of application services, where the messages include the primary key of the timing task corresponding to the expiration time.
In detail, the service determination module 103 is specifically configured to:
judging whether the expiration time of the timing task is reached;
when the expiration time is reached, determining a plurality of application services of the received message by using a preset listener;
and determining to acquire the application service of the distributed lock from the plurality of application services according to a preset command to obtain a target application service.
Further, the determining to acquire the application service of the distributed lock according to the preset command to obtain the target application service includes:
executing the preset command in the plurality of application services according to the main key of the timing task to obtain a plurality of execution results;
and acquiring the application service corresponding to the successful execution result in the execution results, and judging that the application service acquires the distributed lock to obtain the target application service.
The preset command may be a setnx command, the setnx command takes a primary key (key) as a parameter, and only under the condition that the primary key does not exist, a value corresponding to the primary key is set, and a corresponding execution result is successful; when the main key exists, no action is performed, and the corresponding execution result is failure. When a plurality of application services execute the setnx command at the same time, after one application service is successfully executed, the other application services all fail to be executed.
The task execution module 104 is configured to execute the timing task by using the target application service and the parameter.
In detail, the task execution module 104 is specifically configured to:
splicing the primary key of the timing task with a preset suffix to obtain a corresponding parameter primary key;
searching the parameter of the timing task corresponding to the parameter main key from the remote dictionary service;
and executing the timing task in the target application service by using the parameters.
For example, after the target application service is determined to be the outbound service platform, the corresponding parameter primary key can be obtained according to the primary key of the timing task plus a preset suffix. And then, obtaining a value corresponding to the parameter main key from the remote dictionary service, so as to obtain specific parameters of the timing task, such as tel 123456 and content three-point conference in the afternoon. The outbound service platform starts to execute a timing task, namely calls 123456 for reminding, and the reminding content is a three-point meeting in the afternoon.
Optionally, if the execution of the timing task fails, the re-execution time may be determined according to the timing task; and regenerating the timing task according to the re-execution time, and re-executing the timing task.
In the embodiment of the invention, the parameters of the timing task are stored and can be used as the historical record of the timing task for inquiring.
Fig. 3 is a schematic structural diagram of an electronic device implementing a method for scheduling and executing a timed task according to an embodiment of the present invention.
The electronic device 1 may comprise a processor 10, a memory 11 and a bus, and may further comprise a computer program, such as a timed task scheduling executive 12, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, which includes flash memory, removable hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device 1, such as a removable hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device 1. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 11 may be used not only to store application software installed in the electronic device 1 and various types of data, such as codes of the scheduled task scheduling execution program 12, but also to temporarily store data that has been output or will be output.
The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged 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. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device 1 by running or executing programs or modules (e.g., a timing task scheduling execution program, etc.) stored in the memory 11 and calling data stored in the memory 11.
The bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
Fig. 3 shows only an electronic device with components, and it will be understood by those skilled in the art that the structure shown in fig. 3 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than those shown, or some components may be combined, or a different arrangement of components.
For example, although not shown, the electronic device 1 may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so as to implement functions of charge management, discharge management, power consumption management, and the like through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device 1 may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device 1 may further include a network interface, and 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 are generally used for establishing a communication connection between the electronic device 1 and other electronic devices.
Optionally, the electronic device 1 may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the electronic device 1 and for displaying a visualized user interface, among other things.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The timed task scheduling executive 12 stored in the memory 11 of the electronic device 1 is a combination of instructions that, when executed in the processor 10, can implement:
receiving a timing task request, and generating a timing task corresponding to the timing task request based on a remote dictionary service;
storing the parameters of the timing task in the remote dictionary service according to the timing task request;
determining a target application service based on a preset listener and a distributed lock;
executing the timed task using the target application service and the parameters.
Specifically, the specific implementation method of the processor 10 for the instruction may refer to the description of the relevant steps in the embodiments corresponding to fig. 1 to fig. 3, which is not repeated herein.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. The computer readable storage medium may be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
The present invention also provides a computer-readable storage medium, storing a computer program which, when executed by a processor of an electronic device, may implement:
receiving a timing task request, and generating a timing task corresponding to the timing task request based on a remote dictionary service;
storing the parameters of the timing task in the remote dictionary service according to the timing task request;
determining a target application service based on a preset listener and a distributed lock;
executing the timed task using the target application service and the parameters.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A method for scheduling and executing a timed task, the method comprising:
receiving a timing task request, and generating a timing task corresponding to the timing task request based on a remote dictionary service;
storing the parameters of the timing task in the remote dictionary service according to the timing task request;
determining a target application service based on a preset listener and a distributed lock;
executing the timed task using the target application service and the parameters.
2. The method for scheduled execution of a timed task according to claim 1, wherein the generating of the timed task corresponding to the timed task request based on a remote dictionary service comprises:
combining the type and the universal unique identification code in the timing task request according to a preset format to generate a main key;
obtaining the expiration time by carrying out time calculation on specific parameters in the timing task request;
generating a timing task in the remote dictionary service corresponding to the primary key and the expiration time.
3. The method for scheduling and executing a timed task according to claim 2, wherein the obtaining of the expiration time by performing time calculation on specific parameters in the timed task request comprises:
acquiring the execution time of the timing task from the specific parameters of the timing task request;
acquiring current time;
and calculating the time interval between the execution time of the timing task and the current time to obtain the expiration time.
4. The method for scheduling and executing the timed task according to claim 2, wherein the step of storing the parameter of the timed task in the remote dictionary service according to the timed task request comprises the following steps:
adding a preset suffix to generate a parameter primary key after the primary key of the timing task generates a parameter;
acquiring specific parameters in the timing task request;
and writing the specific parameters into the remote dictionary service together as the values corresponding to the parameter primary keys.
5. The method for scheduled execution of a timed task according to claim 2, wherein said executing the timed task using the target application service and the parameters comprises:
splicing the primary key of the timing task with a preset suffix to obtain a corresponding parameter primary key;
searching the parameter of the timing task corresponding to the parameter main key from the remote dictionary service;
and executing the timing task in the target application service by using the parameters.
6. The method for scheduled execution of a timed task according to claim 1, wherein said determining a target application service based on a preset listener and a distributed lock comprises:
judging whether the expiration time of the timing task is reached;
when the expiration time is reached, determining a plurality of application services of the received message by using a preset listener;
and determining to acquire the application service of the distributed lock from the plurality of application services according to a preset command to obtain a target application service.
7. The method for scheduling and executing the timed task according to any one of claims 1 to 6, wherein the determining, according to a preset command, an application service for acquiring the distributed lock from the plurality of application services to obtain a target application service includes:
executing the preset command in the plurality of application services according to the main key of the timing task to obtain a plurality of execution results;
and acquiring the application service corresponding to the successful execution result in the execution results, and judging that the application service acquires the distributed lock to obtain the target application service.
8. A device for scheduling and executing timed tasks, the device comprising:
the task generation module is used for receiving a timing task request and generating a timing task corresponding to the timing task request based on a remote dictionary service;
the parameter storage module is used for storing the parameters of the timing task in the remote dictionary service according to the timing task request;
the service determining module is used for determining target application service based on a preset monitor and a distributed lock;
and the task execution module is used for executing the timing task by using the target application service and the parameters.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method of scheduled task execution according to any of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the timed task scheduling execution method according to any one of claims 1 to 7.
CN202110083321.2A 2021-01-21 2021-01-21 Timing task scheduling execution method and device, electronic equipment and storage medium Pending CN112860394A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110083321.2A CN112860394A (en) 2021-01-21 2021-01-21 Timing task scheduling execution method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110083321.2A CN112860394A (en) 2021-01-21 2021-01-21 Timing task scheduling execution method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112860394A true CN112860394A (en) 2021-05-28

Family

ID=76008897

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110083321.2A Pending CN112860394A (en) 2021-01-21 2021-01-21 Timing task scheduling execution method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112860394A (en)

Similar Documents

Publication Publication Date Title
CN111651471B (en) Target data query method and device, electronic equipment and storage medium
CN111787171B (en) Automatic outbound method, device, electronic equipment and computer readable storage medium
CN112015815B (en) Data synchronization method, device and computer readable storage medium
CN113342472A (en) Micro-service cluster creating method and device, electronic equipment and readable storage medium
CN111538573A (en) Asynchronous task processing method and device and computer readable storage medium
CN112685117A (en) System language internationalization maintenance method, device and computer readable storage medium
CN111880948A (en) Data refreshing method and device, electronic equipment and computer readable storage medium
CN112256783A (en) Data export method and device, electronic equipment and storage medium
CN111784318A (en) Data processing method and device, electronic equipment and storage medium
CN114722437A (en) Cross-APP unique identifier generation method, device, equipment and storage medium
CN112464619B (en) Big data processing method, device and equipment and computer readable storage medium
CN113094125A (en) Business process processing method, device, server and storage medium
CN111901224A (en) Method, device and equipment for loading delayed messages and computer readable storage medium
CN110908644A (en) Configuration method and device of state node, computer equipment and storage medium
CN112860394A (en) Timing task scheduling execution method and device, electronic equipment and storage medium
CN115687384A (en) UUID (user identifier) identification generation method, device, equipment and storage medium
CN115145870A (en) Method and device for positioning reason of failed task, electronic equipment and storage medium
CN112540839A (en) Information changing method, device, electronic equipment and storage medium
CN112686759A (en) Account checking monitoring method, device, equipment and medium
CN112380820A (en) Automatic data backfilling method and device, electronic equipment and computer storage medium
CN113347451A (en) Video uploading method and device, electronic equipment and computer readable storage medium
CN109669867B (en) Test apparatus, automated test method, and computer-readable storage medium
CN112631675A (en) Workflow configuration method, device, equipment and computer readable storage medium
CN112532721B (en) Cluster calling method and device, electronic equipment and storage medium
CN111506644A (en) Application data processing method and device and electronic equipment

Legal Events

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