CN114490135A - Task processing method and device, electronic equipment and storage medium - Google Patents

Task processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114490135A
CN114490135A CN202210139652.8A CN202210139652A CN114490135A CN 114490135 A CN114490135 A CN 114490135A CN 202210139652 A CN202210139652 A CN 202210139652A CN 114490135 A CN114490135 A CN 114490135A
Authority
CN
China
Prior art keywords
task
execution logic
target
target task
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210139652.8A
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 CN202210139652.8A priority Critical patent/CN114490135A/en
Publication of CN114490135A publication Critical patent/CN114490135A/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/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/10Office automation; Time management
    • G06Q10/103Workflow collaboration or project management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Human Resources & Organizations (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • General Business, Economics & Management (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses a task processing method and device, electronic equipment and a storage medium, and is applied to the technical field of data processing. The method can comprise the following steps: receiving a target task notification, wherein the target task notification carries a task identifier corresponding to a target task; determining target task execution logic corresponding to the target task according to the task identifier; determining the on-off state of the target task execution logic, wherein the on-off state comprises an on state or an off state; and if the switch state is the opening state, executing the target task according to the target task execution logic. The embodiment of the method is beneficial to reducing the code coupling degree and realizing the unified management of the task notification. The embodiment of the present application can also be applied to the technical field of block chains, such as storing log data of each task execution logic into a block chain.

Description

Task processing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a task processing method and apparatus, an electronic device, and a storage medium.
Background
Various task execution logics can be configured in each business system (such as a cooperative office system, a financial system and the like), and when the task notification is received, the business system can call the task execution logics to execute the corresponding tasks. At present, if a task execution logic of a task is added to a business system, a task verification logic for determining whether the task can be executed needs to be written in the task execution logic. Because each task verification logic needs to be independently realized in each task execution logic, the code coupling degree between the task verification logic and the task execution logic is high, the expansion is difficult, and the maintainability is low.
Disclosure of Invention
The embodiment of the application provides a task processing method and device, an electronic device and a storage medium, which are beneficial to reducing the code coupling degree and realizing the unified management of task notification.
In one aspect, an embodiment of the present application discloses a task processing method, where the method includes:
receiving a target task notification, wherein the target task notification carries a task identifier corresponding to a target task;
determining target task execution logic corresponding to the target task according to the task identifier;
determining a switch state of the target task execution logic, wherein the switch state comprises an opening state or a closing state;
and if the switch state is the opening state, executing the target task according to the target task execution logic.
On the other hand, the embodiment of the present application discloses a task processing device, the device includes:
the receiving unit is used for receiving a target task notification, and the target task notification carries a task identifier corresponding to a target task;
the processing unit is used for determining a target task execution logic corresponding to the target task according to the task identifier;
the processing unit is further configured to determine a switch state of the target task execution logic, where the switch state includes an on state or an off state;
and the processing unit is also used for executing the target task according to the target task execution logic if the switch state is the starting state.
In yet another aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, where the memory is used to store a computer program, and the computer program includes program instructions, and the processor is configured to perform the following steps:
receiving a target task notification, wherein the target task notification carries a task identifier corresponding to a target task;
determining target task execution logic corresponding to the target task according to the task identifier;
determining a switch state of the target task execution logic, wherein the switch state comprises an opening state or a closing state;
and if the switch state is the opening state, executing the target task according to the target task execution logic.
In another aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer program instructions are stored, and when executed by a processor, the computer program instructions are configured to perform the following steps:
receiving a target task notification, wherein the target task notification carries a task identifier corresponding to a target task;
determining target task execution logic corresponding to the target task according to the task identifier;
determining a switch state of the target task execution logic, wherein the switch state comprises an opening state or a closing state;
and if the switch state is the opening state, executing the target task according to the target task execution logic.
In yet another aspect, embodiments of the present application disclose a computer program product or a computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to execute the task processing method.
The application provides a task processing scheme, which can receive a target task notification, determine the on-off state of a target task execution logic corresponding to a target task according to a task identifier, and execute the target task according to the target task execution logic if the on-off state of the target task execution logic is in an on state. Therefore, the switching states of all task execution logics can be managed in a unified mode, the judgment logics for judging whether the tasks are executed or not in the task execution logics are reduced, the code coupling degree is favorably reduced, and the task notification is managed in a unified mode.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic structural diagram of a service system provided in an embodiment of the present application;
fig. 2 is a schematic flowchart of a task processing method provided in an embodiment of the present application;
fig. 3 is a schematic flowchart of a task processing method provided in an embodiment of the present application;
FIG. 4 is a schematic structural diagram of a task processing device according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The application provides a task processing scheme, which can receive a target task notification, determine the on-off state of a target task execution logic corresponding to a target task according to a task identifier, and execute the target task according to the target task execution logic if the on-off state of the target task execution logic is in an on state. Therefore, the switching states of all task execution logics can be managed in a unified mode, the judgment logics for judging whether the tasks are executed or not in the task execution logics are reduced, the code coupling degree is favorably reduced, and the task notification is managed in a unified mode.
In a possible implementation manner, the task processing scheme of the present application may be applied to a business system, for example, please refer to fig. 1, where fig. 1 is a schematic structural diagram of a business system provided in an embodiment of the present application. A common management component and at least one task execution logic may be included in the business system. The business system may refer to an application system that provides a service, such as an application service like a financial system, a transaction system, etc. The service system can be arranged in the electronic equipment, and then the common management component is called to receive the task notification sent by the task initiator, the target task execution logic corresponding to the target task is determined according to the task identifier, and the on-off state of the target task execution logic is determined, so that the task notification is uniformly managed through the common management component. The task notification may be a notification for triggering the service system to execute a corresponding task, and the task notification may carry a task identifier, where the task identifier may be a unique identifier of the task, so as to distinguish different tasks.
The common management component may include common validation logic for task notifications. For example, the common verification logic may include a judgment logic that notifies the task of the switch state of the corresponding task execution logic; for another example, the common validation logic may include logic to validate whether the task execution logic corresponding to the task notification is executing the task; as another example, the common verification logic may include logic to verify identity information of a task initiator of a task notification, and so on, without limitation. The common management component may also perform unified recording on the processing process of receiving the task notification, and generate log data, for example, the log data may include information such as a call record of each task execution logic, task notification data, an execution track of the task execution logic, time consumed by the task execution logic to execute the task, and whether the task execution logic is abnormal when executing the task, which is not limited herein. It is understood that the common management component can also integrate other common processing logic required by the task execution logic in each task, and the common management component is helpful to adjust or expand the task verification logic, so that the coupling of the codes is reduced. In one possible implementation, a common management component may be included in the business system, which may be a pre-built software toolkit (SDK). In a possible scenario, if each task execution logic in a certain service system needs to be managed uniformly, the software toolkit may be deployed in the service system, and the common verification logic in each task execution logic may be deleted, and the common verification logic does not need to be written in the subsequent task execution logic that needs to be developed, thereby reducing the development cost of the common service for each task execution logic and the cost of subsequent code maintenance.
The task execution logic may be to execute a corresponding task. It will be appreciated that different task execution logic is used to perform different tasks. Each task execution logic is associated with a corresponding task identifier, and the common management component can determine the corresponding task execution logic according to the task identifier carried in the task identifier. For example, the task execution logic of the task execution logic may synchronize the client information to another service system, and when the switch state of the task execution logic is in the on state, the task execution logic may execute the task of synchronizing the client information to another service system.
The task initiator may be a task scheduling platform, the task scheduling platform may provide a task scheduling configuration page, and the task scheduling configuration page may provide information such as a task that a user configures to be executed and a trigger time of the task, and then when time reaches the trigger time, the task scheduling platform sends a task notification to the service system, so that the service system executes the task according to the corresponding task execution logic. For example, a user configures a task for querying another service system based on a task scheduling configuration page, then performs calculation and stores the task in a database, the triggering time of the task is that the task is executed every 5 minutes, the task scheduling platform can send a task notification to the service system every 5 minutes, then the service system calls a common management component to receive the task notification, then verifies the on-off state of the task execution logic and the identity information of the task initiator indicated by the task notification, and if the task execution logic is in the on state and the identity information of the task initiator passes verification, the service system forwards the task notification to the corresponding task execution logic through the common management component, so that the task execution logic can query the data of another service system, then perform calculation and store the data in the database.
It should be noted that, in the embodiments of the present application, except for the specific description, related data such as user information, log data, etc. are referred to, when the embodiments of the present application are applied to specific products or technologies, user permission or consent needs to be obtained, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related countries and regions.
The technical solution of the present application may be applied to an electronic device, where the electronic device may be a terminal, a server, or other devices for performing task processing, and the present application is not limited thereto. And (4) optional. The server can be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, and can also be a cloud server for providing basic cloud computing services such as cloud service, a cloud database, cloud computing, cloud storage, network service, middleware service, big data and artificial intelligence platforms and the like. The terminal may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, and the like.
Based on the above description, an embodiment of the present application provides a task processing method. Referring to fig. 2, fig. 2 is a schematic flowchart of a task processing method according to an embodiment of the present disclosure. The method may be performed by the above mentioned electronic device. The task processing method may include the following steps.
S201, receiving a target task notification.
And the target task notification carries a task identifier corresponding to the target task. As described above, the target task notification may be a notification for triggering the business system to execute the corresponding target task. The target task notification may also carry identity information of the task initiator, where the identity information may be an equipment identifier, a platform identifier, a user identifier, and the like of the task initiator, and is not limited herein. The target task may be a single machine task or a multi-machine task, which is not limited herein.
S202, determining target task execution logic corresponding to the target task according to the task identifier.
The target task execution logic may be an execution module corresponding to the target task, that is, a task execution logic corresponding to the task identifier carried by the target task notification. It can be understood that, as described above, each task execution logic in the service system may associate a corresponding task identifier, and then the task execution logic that matches the task identifier carried by the associated task identifier and the target task notification may be determined as the target task execution logic.
And S203, determining the switch state of the target task execution logic.
Wherein the switch state comprises an on state or an off state. If the task execution logic is in the open state, the task execution logic can normally execute the task, and if the task execution logic is in the closed state, the task execution logic cannot execute the task.
In a possible implementation manner, the on-off state of each task execution logic in the business system may be stored in the target storage area, and further determining the on-off state of the target task execution logic may be: and acquiring the switch state of the target task execution logic from the target storage area. The target storage area may be a storage area dedicated to storing the on/off state of the task execution logic. It will be appreciated that the retrieval of the switch state of the target task execution logic from the target storage area may be performed by the common management component described above. In the target storage area, the on-off state of each task execution logic may be stored in association with a task identifier corresponding to the task execution logic, and when the on-off state of the target task execution logic is acquired from the target storage area through the common management component, the on-off state associated with the task identifier matched with the task identifier carried by the target task notification may be acquired from the target storage area as the on-off state of the target task execution logic.
And S204, if the switch state is the opening state, executing the target task according to the target task execution logic.
As described above, if the task execution logic is in the on state, it indicates that the task execution logic can normally execute the task, and thus the service system can execute the target task according to the target task execution logic, and specifically, the common management component can trigger the target task execution logic according to the target task notification, so that the target task execution logic executes the corresponding task after being triggered by the target task notification. Therefore, when the common management component detects that the on-off state of the target task execution logic is the on-state, the target task execution logic is called to execute the target task, so that the on-off state of each task execution logic is uniformly detected, and the task execution logic is prevented from being directly called to execute the task when the service system is abnormal.
In a possible scenario, the embodiment of the present application may control whether each task execution logic can execute the corresponding task by controlling the on-off state of each task execution logic. It can be understood that whether each task execution logic can execute the corresponding task can be controlled by respectively adjusting the switch state of each task execution logic; according to the method and the device, whether each task execution logic can execute the corresponding task or not can be controlled in a unified mode by controlling the on-off state of each task execution logic in a unified mode, and therefore when the business system is abnormal, each task execution logic can be forbidden to execute a new task quickly, the problem that the business system still executes the task when the business system is abnormal, the task possibly fails or the abnormity of the business system is aggravated is reduced.
In a possible implementation manner, if the on-off state of the target task execution logic is the off state, a prompt message is sent to the target client to prompt that the target task execution logic is the off state. The target client may be a preset client configured to receive a prompt message prompting that the target task execution logic is in an off state. It will be appreciated that sending the hints information to the target clients can be performed by the common management component described above. For example, the preset client may be a client corresponding to a manager of the service system, and the manager may control the task that is not executed because the task execution logic is in the off state through the received prompt information, which is helpful for the manager to better grasp the task execution condition, and perform corresponding processing, such as adjusting the on/off state of the target task execution logic to the on state, reconfiguring the trigger time of the target task, or checking whether the target task execution logic is abnormal, and the like, where no limitation is made here.
The application provides a task processing scheme, which can receive a target task notification, determine the on-off state of a target task execution logic corresponding to a target task according to a task identifier, and execute the target task according to the target task execution logic if the on-off state of the target task execution logic is in an on state. Therefore, the switching states of all task execution logics can be managed in a unified mode, the judgment logics for judging whether the tasks are executed or not in the task execution logics are reduced, the code coupling degree is favorably reduced, and the task notification is managed in a unified mode.
Referring to fig. 3, fig. 3 is a schematic flowchart of a task processing method according to an embodiment of the present disclosure. The method may be performed by the above mentioned electronic device. The task processing method may include the following steps.
S301, receiving a target task notification.
S302, determining target task execution logic corresponding to the target task according to the task identifier.
The relevant description of steps S301-S302 may refer to the relevant description of steps S201-S202, which is not described herein again.
And S303, determining the on-off state of the target task execution logic.
In a possible implementation manner, the switching state of each task execution logic in the service system may be determined by the switching state indicated by the received switch configuration instruction, and specifically includes the following steps: receiving a switch configuration instruction. And secondly, updating the switch state according to the switch configuration instruction, and storing the updated switch state into a target storage area. And further acquiring the switch state of the target task execution logic from the target storage area. The switch configuration instruction is used for controlling the switch state of the task execution logic, namely updating the switch state of each task execution logic in the service system. The switch configuration instruction may be a switch configuration instruction sent by a user client, and the switch configuration instruction may carry a task identifier corresponding to a task execution logic whose switch state needs to be updated and a corresponding switch state, or carry task identifiers corresponding to all task execution logics and corresponding switch states. It can be understood that the task identifier carried in the switch state instruction may be a task identifier corresponding to a part or all of task execution logic in the service system, and is not limited herein. In a possible implementation manner, in the embodiment of the present application, a switch configuration page may also be provided to be displayed in the user client, and then the user may configure the switch states of each task execution logic based on the switch configuration page, where in the switch configuration page, the user may configure the switch states of all or part of the task execution logics in the business system, and when the user client detects a confirmation operation for the switch states of each configured task execution logic of the current switch configuration page (for example, when it is detected that the user clicks a control for instructing to confirm the configuration content of the current switch configuration page), the user client sends a switch configuration instruction to the electronic device. For example, in the switch configuration page, the user adjusts the switch state of the task execution logic a from the on state to the off state, and adjusts the switch state of the task execution logic B from the off state to the on state, the user client sends a switch configuration instruction to the electronic device, and the electronic device updates the switch state associated with the task identifier of the task execution logic a in the target storage area to the off state, and updates the switch state associated with the task identifier of the task execution logic B in the target storage area to the on state, thereby implementing unified control of the switch states of the task execution logics through the switch configuration page.
In a possible implementation manner, the on-off state of each task execution logic in the service system may be determined by log data of each task execution logic detected by the common management component, and specifically may include the following steps: detecting log data of each task execution logic, and if detecting that the log data of the task execution logic meets a switch adjustment condition, adjusting the switch state of the task execution logic according to the switch adjustment condition, wherein the switch adjustment condition comprises an opening condition or a closing condition. And secondly, storing the adjusted on-off state of the task execution logic in a target storage area. And further acquiring the switch state of the target task execution logic from the target storage area. The detecting of the log data of each task execution logic may be that the common management component is invoked to detect the log data of each task execution logic according to the target time interval to determine whether the log data of each task execution logic satisfies the switch adjustment condition. The target time interval may be a time interval for detecting log data of each task execution logic in the service system, for example, if the target time interval is 10s, the common management component is called to detect the log data of each task execution logic once every 10 intervals. The switch adjustment condition is used to indicate a condition for adjusting the switch state to an on state or an off state, where the on condition is a condition that needs to be satisfied for adjusting the switch state to the on state, and the off condition is a condition that needs to be satisfied for adjusting the switch state to the off state.
For example, if the shutdown condition is that a task is executed N times at most in the first time period, when the log data indicates that the task execution logic has received three times of task notifications and executed the corresponding task in the target time period, the on-off state of the task execution logic may be determined as the shutdown state; and if the starting condition is that the time that the task execution logic is adjusted to be in the closed state by the service system exceeds a second time period, determining the on-off state of the task execution logic to be in the open state when the log data shows that the time that the task execution logic is more than the second time period from the last time that the service system adjusts the on-off state of the task execution logic to be in the closed state.
For another example, if the turn-off condition is that the time for executing the task by the at least K task execution logics exceeds the corresponding time preset value, the time preset value may be a preset value corresponding to each task execution logic, and in a general case, the time preset value corresponding to each task execution logic may be determined according to an average value of the time required for executing the task by the corresponding task execution logic. For example, an average value of the time required for the corresponding task execution logic to execute the task may be determined as the time preset value, or a constant may be added on the basis of the average value of the time required for the corresponding task execution logic to execute the task as the time preset value. And when the log data shows that the time for executing the tasks of at least K task execution logics exceeds the corresponding time preset value, determining that the log data of the task execution logics meets the closing condition, and determining all task execution logics in the service system or the on-off state of the task execution logics with the time for executing the tasks exceeding the corresponding time preset value as the closing state.
In one possible implementation, the switch states of the task execution logics in the business system can be obtained by combining the switch states indicated by the received switch configuration instructions and the switch states determined by log data of the task execution logics detected by the common management component. Specifically, if the service system receives the switch configuration instruction, the switch state of each task execution logic is updated to the switch state indicated by the switch configuration instruction, and then the switch state is subsequently adjusted according to the detected log data of each task execution logic based on the switch state indicated by the switch configuration instruction. For example, the switch state of the task execution logic a is adjusted to be the off state, when the switch configuration instruction is received to adjust the switch state of the task execution logic a to be the on state, the switch state stored in association with the task identifier of the task execution logic a in the target storage area is the on state, in the process that the subsequent task execution logic processes a plurality of tasks, if the common management component detects that the log data of the task execution logic a meets the off condition, the switch state of the task execution logic a is adjusted to be the off state, and then the switch state stored in association with the task identifier of the task execution logic a in the target storage area is adjusted to be the off state.
In a possible implementation manner, as described above, if the target task notification carries the identity information of the task initiator, before determining the on-off state of the target task execution logic, the common management component may be further invoked to verify the identity information of the task initiator, which may specifically include the following steps: verifying the identity information of the task initiator notified by the target task. The verifying the identity information of the task initiator may be to verify whether the task initiator indicated by the identity information is an authorized platform or user. If the initiator of the target task notification indicated by the identity information is detected to be the target task scheduling platform, executing the step of determining the on-off state of the target task execution logic; the target task scheduling platform is an authorized task scheduling platform. In one possible implementation, if it is detected that the identity information indicates that the initiator of the target task notification is not the target task scheduling platform, the common management component may not perform the subsequent steps. Therefore, the unified verification of the identity of the task initiator can be realized, and the task execution logic can be triggered only by the authorized task initiator. Therefore, the common management component receives the target task notification and verifies the task notification, and the task execution logic can avoid directly receiving the target task notification to perform a series of verification logics on the target task notification, so that the situation that the task execution is influenced by the verification of the task due to high coupling degree between the task execution logic and the verification logics of the task is reduced.
And S304, if the on-off state of the target task execution logic is the opening state, acquiring the task lock of the target task from the task lock database.
Wherein the task lock is to identify whether the target task execution logic is executing the target task. The task lock of the target task is obtained from the task lock database, and the task lock of the target task is obtained from the task lock database through the common management component. If the task execution logic is executing the task, the task lock cannot be acquired; if the task execution logic is not executing the task, the task lock can be acquired. In a possible implementation manner, the task lock may be a database lock or a redis lock, and the like, the same task (that is, the same task execution logic) may only be associated with one lock, and each time the common management component receives a task notification, the corresponding task lock needs to be acquired, and after the task execution logic executes the task, the task lock corresponding to the task may be released, that is, when the task lock of a certain task is already acquired and is not released, the common management component cannot acquire the corresponding task lock, so that the task is prevented from being repeatedly triggered, and the problem of concurrent execution of the task due to repeated triggering of the task, which causes the problem of repeated processing and data lock of data, which causes an abnormality of a service system or a disorder of a data result, is avoided, thereby avoiding that major production accidents are all caused.
S305, if the task lock of the target task is acquired, executing the step of executing the target task according to the target task execution logic.
As described above, if the common management component acquires the task lock of the target task, it indicates that the target task execution logic is not executing the task, and the target task execution logic may be directly triggered to execute the target task.
And S306, if the task lock of the target task is not acquired, storing the target task notification in a cache region.
As described above, if the task lock of the target task is acquired, indicating that the target task execution logic is executing the task, the task execution logic is not triggered to execute the task temporarily, but the target task notification is stored in the cache area, so that the task execution logic is triggered to execute the task after the target task execution logic finishes executing the task.
In a possible implementation manner, if the task lock of the target task is not acquired, a prompt message may be directly returned to the target client to prompt the target task execution logic to execute the task, and the newly received target task cannot be executed.
In a possible implementation manner, if the task lock of the target task is not acquired, whether the electronic device directly returns the prompt information to the target client or stores the target task notification to the cache region may be determined according to the number of target task notifications that have been cached in the current cache region, and if the current cache region has cached target task notifications that are greater than the number threshold, the electronic device may directly return the prompt information to the target client, so that accumulation of the target task notifications may be avoided, and the electronic device may directly return the prompt information to the target client if the number threshold is exceeded, without waiting for the target task to be executed after the target task execution logic completes the task.
S307, acquiring a task lock of the target task according to a preset time interval until the task lock of the target task is acquired, acquiring a target task notification from the cache region, and executing the step of executing the target task according to the target task execution logic.
The preset time interval may be a time interval for acquiring a task lock of the target task. For example, if the preset time interval is 5s, the task lock of the target task is acquired every 5 s. If the task lock of the target task is acquired, the task executed by the target task execution logic is completed, and the corresponding task lock is released, the common management component can acquire the task lock of the target task. Optionally, after the target task notification is obtained from the cache region, the data of the target task notification may be deleted from the cache region, so as to reduce the space occupation of the cache region. Therefore, by regularly pulling the task lock, the task execution logic can be triggered to execute the task when the task lock is pulled.
In a possible implementation manner, if the task lock of the target task is not acquired, after the target task notification is stored in the cache region, the common management component can be called to acquire log data of the target task execution logic at regular time, when the log data indicates that the target task execution logic has executed the task, the common management component is called to acquire the task lock of the target task again, and as the target task execution logic has executed the task and releases the corresponding task lock, the task lock of the target task can be acquired at this time, and then the target task notification is acquired from the cache region and the step of executing the target task according to the target task execution logic is executed. Therefore, the execution condition of the target task execution logic can be directly detected according to the log data, and further the task lock does not need to be acquired according to the preset time interval.
It is understood that after step S304, step S305 is executed or steps S306-S307 are executed to control the result of actually acquiring the task lock.
The application provides a task processing scheme, which can receive a target task notification, determine the on-off state of a target task execution logic corresponding to a target task according to a task identifier, and execute the target task according to the target task execution logic if the on-off state of the target task execution logic is in an on state. Therefore, the switching states of all task execution logics can be managed in a unified mode, the judgment logics for judging whether the tasks are executed or not in the task execution logics are reduced, the code coupling degree is favorably reduced, and the task notification is managed in a unified mode.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a task processing device according to an embodiment of the present disclosure. Alternatively, the task processing device may be disposed in the electronic device. As shown in fig. 4, the task processing device described in the present embodiment may include:
a receiving unit 401, configured to receive a target task notification, where the target task notification carries a task identifier corresponding to a target task;
a processing unit 402, configured to determine, according to the task identifier, a target task execution logic corresponding to the target task;
the processing unit 402 is further configured to determine a switch state of the target task execution logic, where the switch state includes an on state or an off state;
the processing unit 402 is further configured to execute the target task according to the target task execution logic if the switch state is an on state.
In one implementation, the processing unit 402 is further configured to:
receiving a switch configuration instruction, wherein the switch configuration instruction is used for controlling the switch state of task execution logic;
updating the switch state according to the switch configuration instruction, and storing the updated switch state into a target storage area;
the processing unit 402 is specifically configured to:
and acquiring the switch state of the target task execution logic from the target storage area.
In one implementation, the processing unit 402 is further configured to:
detecting log data aiming at each task execution logic, and if detecting that the log data of the task execution logic meets a switch adjustment condition, adjusting the switch state of the task execution logic according to the switch adjustment condition; the switch adjustment condition comprises an on condition or an off condition;
storing the switch state of the adjusted task execution logic to a target storage area;
the processing unit 402 is specifically configured to:
and acquiring the switch state of the target task execution logic from the target storage area.
In one implementation, the processing unit 402 is further configured to:
acquiring a task lock of the target task from a task lock database; the task lock is used for identifying whether the target task execution logic is executing a task;
and if the task lock of the target task is acquired, executing the step of executing the target task according to the target task execution logic.
In one implementation, the processing unit 402 is further configured to:
if the task lock of the target task is not acquired, storing the target task notification to a cache region;
and acquiring a task lock of the target task according to a preset time interval until the task lock of the target task is acquired, acquiring the target task notification from the cache region and executing the step of executing the target task according to the target task execution logic.
In one implementation, the processing unit 402 is further configured to:
and if the on-off state of the target task execution logic is the off state, sending a prompt message to a target client to prompt that the target task execution logic is the off state.
In one implementation, the target task notification carries identity information of a task initiator; the processing unit 402 is further configured to:
verifying the identity information of the task initiator notified by the target task;
if the fact that the identity information indicates that the initiator of the target task notification is a target task scheduling platform is detected, the step of determining the on-off state of the target task execution logic is executed; the target task scheduling platform is an authorized task scheduling platform.
Referring to fig. 5, fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. The electronic device described in this embodiment includes: a processor 501 and a memory 502. Optionally, the electronic device may further include a network interface or a power supply module. The processor 501 and the memory 502 can exchange data with each other.
The Processor 501 may be a Central Processing Unit (CPU), and may also be other general purpose processors, Digital Signal Processors (DSP), Application Specific Integrated Circuits (ASIC), Field-Programmable Gate arrays (FPGA) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and so on. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The network interface may include an input device, such as a control panel, a microphone, a receiver, etc., and/or an output device, such as a display screen, a transmitter, etc., to name but a few. For example, in an application embodiment, the network interface may include a receiver and a transmitter.
The memory 502 may include both read-only memory and random access memory, and provides program instructions and data to the processor 501. A portion of the memory 502 may also include non-volatile random access memory. Wherein, the processor 501, when calling the program instruction, is configured to perform:
receiving a target task notification, wherein the target task notification carries a task identifier corresponding to a target task;
determining target task execution logic corresponding to the target task according to the task identifier;
determining a switch state of the target task execution logic, wherein the switch state comprises an opening state or a closing state;
and if the switch state is the opening state, executing the target task according to the target task execution logic.
In one implementation, the processor 501 is further configured to:
receiving a switch configuration instruction, wherein the switch configuration instruction is used for controlling the switch state of task execution logic;
updating the switch state according to the switch configuration instruction, and storing the updated switch state into a target storage area;
the processor 501 is specifically configured to:
and acquiring the switch state of the target task execution logic from the target storage area.
In one implementation, the processor 501 is further configured to:
detecting log data aiming at each task execution logic, and if detecting that the log data of the task execution logic meets a switch adjustment condition, adjusting the switch state of the task execution logic according to the switch adjustment condition; the switch adjustment condition comprises an on condition or an off condition;
storing the switch state of the adjusted task execution logic to a target storage area;
the processor 501 is specifically configured to:
and acquiring the switch state of the target task execution logic from the target storage area.
In one implementation, the processor 501 is further configured to:
acquiring a task lock of the target task from a task lock database; the task lock is used for identifying whether the target task execution logic is executing a task;
and if the task lock of the target task is acquired, executing the step of executing the target task according to the target task execution logic.
In one implementation, the processor 501 is further configured to:
if the task lock of the target task is not acquired, storing the target task notification to a cache region;
and acquiring a task lock of the target task according to a preset time interval until the task lock of the target task is acquired, acquiring the target task notification from the cache region and executing the step of executing the target task according to the target task execution logic.
In one implementation, the processor 501 is further configured to:
and if the on-off state of the target task execution logic is the off state, sending a prompt message to a target client to prompt that the target task execution logic is the off state.
In one implementation, the target task notification carries identity information of a task initiator; the processor 501 is further configured to:
verifying the identity information of the task initiator notified by the target task;
if the fact that the identity information indicates that the initiator of the target task notification is a target task scheduling platform is detected, the step of determining the on-off state of the target task execution logic is executed; the target task scheduling platform is an authorized task scheduling platform.
Optionally, the program instructions may also implement other steps of the method in the above embodiments when executed by the processor, and details are not described here.
The present application further provides a computer-readable storage medium, in which a computer program is stored, the computer program comprising program instructions, which, when executed by a processor, cause the processor to perform the above method, such as performing the above method performed by an electronic device, which is not described herein in detail.
Optionally, the storage medium, such as a computer-readable storage medium, referred to herein may be non-volatile or volatile.
Alternatively, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like. The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. 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.
It should be noted that, for simplicity of description, the above-mentioned embodiments of the method are described as a series of acts or combinations, but those skilled in the art should understand that the present application is not limited by the order of acts described, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
Embodiments of the present application also provide a computer program product or computer program comprising computer instructions stored in a computer-readable storage medium. The computer instructions are read by a processor of a computer device from a computer-readable storage medium, and the computer instructions are executed by the processor to cause the computer device to perform the steps performed in the embodiments of the methods described above. For example, the computer device may be a terminal, or may be a server.
The above detailed description is provided for a task processing method, a task processing apparatus, an electronic device, and a storage medium provided in the embodiments of the present application, and a specific example is applied in the present application to explain the principles and embodiments of the present application, and the description of the above embodiments is only used to help understanding the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method for processing a task, the method comprising:
receiving a target task notification, wherein the target task notification carries a task identifier corresponding to a target task;
determining target task execution logic corresponding to the target task according to the task identifier;
determining a switch state of the target task execution logic, wherein the switch state comprises an opening state or a closing state;
and if the switch state is the opening state, executing the target task according to the target task execution logic.
2. The method of claim 1, further comprising:
receiving a switch configuration instruction, wherein the switch configuration instruction is used for controlling the switch state of task execution logic;
updating the switch state according to the switch configuration instruction, and storing the updated switch state into a target storage area;
the determining the switch state of the target task execution logic comprises:
and acquiring the switch state of the target task execution logic from the target storage area.
3. The method of claim 1, further comprising:
detecting log data aiming at each task execution logic, and if detecting that the log data of the task execution logic meets a switch adjustment condition, adjusting the switch state of the task execution logic according to the switch adjustment condition; the switch adjustment condition comprises an on condition or an off condition;
storing the switch state of the adjusted task execution logic to a target storage area;
the determining the switch state of the target task execution logic comprises:
and acquiring the switch state of the target task execution logic from the target storage area.
4. The method of any of claims 1-3, wherein prior to executing the target task according to the target task execution logic, further comprising:
acquiring a task lock of the target task from a task lock database; the task lock is used for identifying whether the target task execution logic is executing a task;
and if the task lock of the target task is acquired, executing the step of executing the target task according to the target task execution logic.
5. The method of claim 4, further comprising:
if the task lock of the target task is not acquired, storing the target task notification to a cache region;
and acquiring a task lock of the target task according to a preset time interval until the task lock of the target task is acquired, acquiring the target task notification from the cache region and executing the step of executing the target task according to the target task execution logic.
6. The method of claim 1, further comprising:
and if the on-off state of the target task execution logic is the off state, sending a prompt message to a target client to prompt that the target task execution logic is the off state.
7. The method according to claim 1, wherein the target task notification carries identity information of a task initiator; before determining the switch state of the target task execution logic, the method further includes:
verifying the identity information of the task initiator notified by the target task;
if the fact that the identity information indicates that the initiator of the target task notification is a target task scheduling platform is detected, the step of determining the on-off state of the target task execution logic is executed; the target task scheduling platform is an authorized task scheduling platform.
8. A data processing apparatus, comprising:
the receiving unit is used for receiving a target task notification, and the target task notification carries a task identifier corresponding to a target task;
the processing unit is used for determining a target task execution logic corresponding to the target task according to the task identifier;
the processing unit is further configured to determine a switch state of the target task execution logic, where the switch state includes an on state or an off state;
and the processing unit is also used for executing the target task according to the target task execution logic if the switch state is the starting state.
9. An electronic device comprising a processor, a memory, wherein the memory is configured to store a computer program comprising program instructions, and wherein the processor is configured to invoke the program instructions to perform the method of any of claims 1-7.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions that, when executed by a processor, cause the processor to carry out the method according to any one of claims 1-7.
CN202210139652.8A 2022-02-15 2022-02-15 Task processing method and device, electronic equipment and storage medium Pending CN114490135A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210139652.8A CN114490135A (en) 2022-02-15 2022-02-15 Task processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210139652.8A CN114490135A (en) 2022-02-15 2022-02-15 Task processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114490135A true CN114490135A (en) 2022-05-13

Family

ID=81480922

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210139652.8A Pending CN114490135A (en) 2022-02-15 2022-02-15 Task processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114490135A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115190016A (en) * 2022-07-25 2022-10-14 平安科技(深圳)有限公司 System general switch configuration method, device, equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115190016A (en) * 2022-07-25 2022-10-14 平安科技(深圳)有限公司 System general switch configuration method, device, equipment and storage medium
CN115190016B (en) * 2022-07-25 2023-04-28 平安科技(深圳)有限公司 System general switch configuration method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110661658B (en) Node management method and device of block chain network and computer storage medium
CN107329741B (en) Software distributed upgrading method and device based on fingerprint identification
CN110222107B (en) Data transmission method and related equipment
CN110569251A (en) Data processing method, related equipment and computer readable storage medium
CN110222500A (en) Method for edition management, device, equipment and computer readable storage medium
CN110597918A (en) Account management method and device and computer readable storage medium
CN110995825B (en) Intelligent contract issuing method, intelligent node equipment and storage medium
CN112714158A (en) Transaction processing method, relay network, cross-link gateway, system, medium, and device
CN107844306B (en) Application program repairing method and device, storage medium and terminal
US9830217B2 (en) Selective block-based integrity protection techniques
CN114564757A (en) Data auditing method, device and equipment of block chain and readable storage medium
CN112214519A (en) Data query method, device, equipment and readable medium
CN109657485B (en) Authority processing method and device, terminal equipment and storage medium
US11232205B2 (en) File storage service initiation of antivirus software locally installed on a user device
CN114490135A (en) Task processing method and device, electronic equipment and storage medium
CN113010238A (en) Permission determination method, device and system for micro application call interface
CN116627444A (en) System and method for automatically synchronizing responses and conditions on a device
CN111722994A (en) Task request response method and device
CN112037055A (en) Transaction processing method and device, electronic equipment and readable storage medium
CN111698227B (en) Information synchronization management method, device, computer system and readable storage medium
CN108462713B (en) Method and system for client to perform credibility verification
CN113592645A (en) Data verification method and device
CN114270309A (en) Resource acquisition method and device and electronic equipment
CN110826078A (en) Data storage method, device and system
CN113872923B (en) Transaction method, updating method, device, equipment and storage medium based on blockchain system

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