Task execution method and device, storage medium and electronic equipment
By modeling business tasks as DAG task flows and using independent components to manage task execution, the system load problem caused by the redundancy of the retry fallback mechanism is solved, the task execution logic and retry logic are decoupled, and the system robustness and success rate are improved.
Patent Information
- Application Number
- CN202410003531.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-02
- Publication Date
- 2024-11-15
AI Technical Summary
In existing technologies, as the types of business and the amount of concurrency increase, the redundancy of the retry fallback mechanism increases, leading to an increase in the operating load of the business system and a decrease in its robustness.
The target tasks defined on the business component side are modeled as DAG task flows. The target tasks are executed by calling back the DAG task flows, decoupling the business logic and task execution logic. The target component, which is independent of the business component, manages task execution and maintains retry records in the storage component to realize retry operations.
This reduces redundancy in retry logic, lowers system resource consumption, and improves task execution success rate and the robustness of business systems.
Smart Images

Figure CN118964053A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a task execution method, device, storage medium and electronic device. Background Art
[0002] In the related technology, it is necessary to configure a corresponding retry backup mechanism for each business. As the number of business types increases and the number of concurrent business executions increases, the redundancy of the retry backup mechanism will also increase significantly. If multiple businesses are designed, each business includes its own retry backup logic, which obviously generates a lot of redundancy. The operating load of the business system composed of multiple businesses is increased, and the operating resource usage is increased. The generation of a large amount of redundancy also increases the operating risk of the business system and reduces the robustness of the business system. Summary of the invention
[0003] The embodiments of the present application provide a task execution method, device, storage medium and electronic device to solve at least one of the aforementioned technical problems.
[0004] According to one aspect of an embodiment of the present application, a task execution method is provided, which is applied to a target component, where the target component is a third-party component independent of a business component, and the method includes:
[0005] In response to a callback registration request issued by the business component, register at least one callback interface for a target business, wherein the callback interface is used to trigger a call to a corresponding execution interface in the business component, and the target business is a business associated with the business component;
[0006] In response to a target task execution request for the target business issued by the business component, a target task flow instance corresponding to the target task is obtained, the target task flow instance is triggered to create a corresponding retry record in the storage component, and the target task is executed by calling each callback interface of the target business, and any callback interface updates the retry record according to its own execution result; wherein the storage component is independent of the target component;
[0007] In the case that there is a target retry record that meets the preset condition in the storage component, the task flow instance to be retried corresponding to the target retry record is determined, and a retry operation is performed on the task flow instance to be retried.
[0008] According to one aspect of an embodiment of the present application, a task execution device is provided, which is applied to a target component, where the target component is a third-party component independent of a business component, and the device includes:
[0009] A task flow processing module, used to perform the following operations: in response to a callback registration request issued by the business component, register at least one callback interface for a target business, the callback interface is used to trigger the call of a corresponding execution interface in the business component, and the target business is a business associated with the business component; and, in response to a target task execution request for the target business issued by the business component, obtain a target task flow instance corresponding to the target task, trigger the target task flow instance to create a corresponding retry record in a storage component, and execute the target task by calling each of the callback interfaces of the target business, any of the callback interfaces updates the retry record according to its own execution result; wherein the storage component is independent of the target component;
[0010] The retry module is used to determine the task flow instance to be retried corresponding to the target retry record when there is a target retry record meeting the preset condition in the storage component, and perform a retry operation on the task flow instance to be retried.
[0011] According to one aspect of an embodiment of the present application, a computer device is provided, which includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the above-mentioned task execution method.
[0012] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which at least one instruction, at least one program, a code set or an instruction set is stored, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the above-mentioned task execution method.
[0013] According to one aspect of an embodiment of the present application, a computer program product is provided, the computer program product comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes to implement the above-mentioned task execution method.
[0014] The technical solution provided in the embodiments of the present application can bring the following beneficial effects:
[0015] The embodiment of the present application provides a task execution method, which models the specific target task in the target business defined on the business component side as a DAG task flow that can be executed by calling the callback interface in sequence, and executes the target task by calling back the DAG task flow, thereby decoupling the business logic and the task execution logic. Each business component can register a callback with the target component in the present application, thereby using the task flow service in the target component, thereby reducing the operating load of the business system where each business is located. The task flow service will call back the execution interface in the business component according to the specific target task, thereby managing the execution of the task, without the need for the business component developer to perform additional task management, decoupling the business design and task execution.
[0016] Each task maintains its corresponding retry record during the specific execution process without paying attention to the retry logic, because the target component will traverse the retry records of each task, and retry the relevant task flow instance if retry is needed. This completes the decoupling of the task execution logic and the retry logic, thereby significantly reducing the redundancy generated by the retry logic and reducing the resource usage of the system running each task. The developers of each business component and even the developers of the task execution logic do not need to pay attention to redesigning the retry logic. In other words, the task execution method of the present application realizes the three-way decoupling of business logic, task execution logic and retry backup logic, improves the success rate of task execution, and improves the robustness of the business side and task execution side devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 This is a schematic diagram of a state machine-based retry backup mechanism provided by an embodiment of the present application;
[0019] Figure 2 is a schematic diagram of an application program operating environment provided by an embodiment of the present application;
[0020] Figure 3 is a flowchart of a task execution method provided by an embodiment of the present application;
[0021] Figure 4 This is a callback registration logic diagram provided by an embodiment of the present application. Figure 1 ;
[0022] Figure 5 This is a callback registration logic diagram provided by an embodiment of the present application. Figure 2 ;
[0023] Figure 6 It is a schematic diagram of the target task flow instance execution process provided by an embodiment of the present application;
[0024] Figure 7 It is a retry logic schematic diagram provided by an embodiment of the present application;
[0025] Figure 8 This is a task execution diagram provided by an embodiment of the present application;
[0026] Fig. 9 is a block diagram of a task execution device provided by an embodiment of the present application;
[0027] Fig.10 It is a structural block diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0028] Before introducing the method embodiments provided in the present application, a brief introduction is first given to the relevant terms or nouns that may be involved in the method embodiments of the present application to facilitate understanding by technicians skilled in the art of the present application.
[0029] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which is used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0030] A distributed system is a software system built on a network that is highly cohesive and transparent. Compared with traditional centralized systems, distributed systems divide tasks into multiple parts and distribute them to different computers for processing, thereby improving system performance and reliability. The characteristics of distributed systems include:
[0031] High cohesion: The various components in the distributed system are tightly coupled, and task allocation and data exchange are completed within the system without external intervention.
[0032] Transparency: Users or applications of a distributed system do not need to care about the internal structure and details of the system, they only need to interact with the system through interfaces.
[0033] Reliability: Each component in a distributed system can operate independently, and the failure of a component will not cause the entire system to fail.
[0034] Scalability: Distributed systems can easily add or reduce nodes to adapt to changes in business needs.
[0035] High performance: Distributed systems can significantly improve the system's processing power and response speed by distributing tasks to multiple nodes for processing.
[0036] Intelligent Traffic System (ITS), also known as Intelligent Transportation System, effectively and comprehensively applies advanced science and technology (information technology, computer technology, data communication technology, sensor technology, electronic control technology, automatic control theory, operations research, artificial intelligence, etc.) to transportation, service control and vehicle manufacturing, strengthens the connection between vehicles, roads and users, and thus forms a comprehensive transportation system that ensures safety, improves efficiency, improves the environment and saves energy.
[0037] DAG task flow: refers to the task arrangement method of directed acyclic graph (DAG). In this task flow, there are dependencies between tasks, and the execution order between tasks is determined by the structure of the DAG graph. In the DAG task flow, tasks are divided into several atomic tasks, each of which has specific inputs and outputs. These atomic tasks are arranged in a certain order to form a directed acyclic graph. Each task node represents an atomic task, and each edge represents a dependency. In the DAG task flow, each task node has a certain execution order, which depends on the completion of all its dependent tasks. When all dependent tasks are completed, the task node can start execution. The execution order of tasks is carried out according to the topological sorting of the DAG graph. In order to implement the DAG task flow, the key issues that need to be solved are the dependencies and execution order between tasks. In practical applications, some tools and frameworks can be used to implement the DAG task flow.
[0038] Redis (RemoteDictionary Server): is an open source, high-performance key-value database that supports multiple data types, such as strings, lists, sets, ordered sets, and hashes. Redis is a log-based database that can also be persistent based on memory. Its features include support for data persistence, which can save data in memory to disk, load it again when restarted, and support data backup. Redis has extremely high performance, with a read speed of 110,000 times / s and a write speed of 81,000 times / s. Its rich data types and all operations are atomic, and it also supports atomic execution of several operations after merging.
[0039] HBase is a highly scalable column storage system. The goal of HBase is to process semi-structured sparse data. It can be used in a distributed environment to provide fast and efficient data reading and writing functions. HBase tables are organized into several data blocks, which are divided according to row keys. Each data block contains multiple rows and columns. HBase provides random access based on row keys, allowing users to quickly query and update data. Another important feature of HBase is that it supports dynamic addition of columns. In traditional relational databases, all columns and their types must be specified when building a table, while in HBase, new columns and their types can be added dynamically at runtime. This makes HBase more flexible and easy to use. In addition, HBase also supports version control, and each data block can save multiple versions of data. This can be used to implement data backup and recovery. In general, HBase is a distributed database suitable for large-scale data storage and processing, which provides high availability, high scalability, and high concurrent access capabilities.
[0040] SOS (Storage Optimized Solutions) storage: is a solution for data storage optimization, which is mainly used to solve the problem of large-scale data storage and management. SOS storage usually adopts a distributed architecture to store data on multiple nodes to improve the reliability and scalability of the storage system. The main features of SOS storage include: High reliability: SOS storage usually adopts data redundancy and verification technology to ensure the reliability and integrity of data. At the same time, it also supports automatic backup and recovery functions to prevent data loss. High scalability: SOS storage system can easily expand storage capacity and performance to meet the development needs of business. It usually adopts a distributed architecture, and nodes can be freely increased or decreased to achieve dynamic expansion. High performance: SOS storage usually adopts high-speed cache and optimization algorithms to improve data read and write speed and access efficiency. It can also support concurrent access and parallel processing to provide higher performance. Unified management: SOS storage system provides a unified management interface and tools to facilitate data management and maintenance. It also supports various data backup and recovery strategies to ensure data security and availability. In short, SOS storage is an efficient, reliable and scalable data storage solution suitable for large-scale data storage and management scenarios such as cloud storage and big data analysis.
[0041] KV data refers to key-value data, which means that a specific value is stored and retrieved through a unique key. In the fields of computer science and big data, KV data is widely used in various data storage and management scenarios, such as cache systems, session management, user configuration storage, metadata storage, etc. KV database is a data storage and management system based on the KV data model. It adopts a simple key-value data model, and each record consists of a unique key and a corresponding value. KV database is simple, efficient, flexible and easy to use, and can quickly access and query data. In a distributed environment, KV database usually adopts a distributed architecture to store data on multiple machines to improve the performance and reliability of the system. It supports distributed transactions and data consistency guarantees to provide more reliable data operations. In short, KV data is an efficient, flexible and easy-to-use data storage and management method, which is widely used in various computer science and big data application scenarios.
[0042] The aforementioned data storage components can be used to build a KV database, which can support three types of storage: object storage, block storage, or file storage. Object storage is a technology that stores and manages data as objects (including data and metadata). In object storage, data is stored in a flat structure, and each object has a unique identifier (ID) through which the object can be accessed and operated. Object storage is highly scalable and flexible, and can store a large number of different types of data, such as pictures, videos, documents, etc. In addition, object storage also supports data version control and access control, which can achieve secure sharing and collaboration of data. Block storage is one of the most traditional storage methods. It divides data into fixed-size blocks, each of which has a unique address. Block storage is mainly used to store structured data, such as databases and file systems. File storage is a technology that stores and manages data in the form of files.
[0043] Idempotent records refer to the same operation, no matter how many times it is executed, the result is the same. In data storage and management, idempotency can ensure the consistency and integrity of data. For database operations, idempotency can be achieved through unique indexes, unique data, and state machine constraints. Idempotence is a very important concept in data storage and management, which can ensure the consistency and integrity of data and avoid repeated operations and data conflicts.
[0044] SDK (Software Development Kit) is a toolkit that assists in software development, usually including a series of application programming interfaces and development tools for software development. SDK can provide some specific functions and tools to help developers write and debug software more conveniently.
[0045] A handle is a concept used in computer programming. It refers to an identifier that is usually used to represent a resource or object. A handle is usually a unique integer value that is used to uniquely identify the resource or object in a program.
[0046] Before describing the embodiments of the present application in detail, the relevant technical background related to the embodiments of the present application is introduced to facilitate understanding by those skilled in the art in the field of the present application.
[0047] When executing specific tasks, the business components in the related technology may encounter task execution exceptions. For example, for a specific task of a business that needs to be executed by several subtasks in a specified topological order, the failure of a subtask execution may affect the execution of downstream subtasks, which will cause the overall task execution exception. Especially in scenarios such as long task execution links, long task response times, or high requirements for task execution success rates, it is necessary to increase the task execution success rate as much as possible. Moreover, if the task is implemented in a distributed system, the task execution exception may be caused by factors such as node restart and migration of the distributed system. This exception needs to be compensated as much as possible. Therefore, in order to avoid the decrease in the task execution success rate caused by the subtask execution exception as much as possible, the related technology usually configures a retry guarantee mechanism for the business. The retry guarantee mechanism sets a timed table scan execution logic for the corresponding business. The timed table scan execution logic is used to find subtasks that failed to execute and retry the subtask to improve the subtask execution success rate, thereby improving the task execution success rate.
[0048] The scheduled table scanning execution logic abstracts the specific business process into a state machine containing several states, and records the state and context during execution, thereby building a related record table. Through the background scheduled task table scanning, polling state machine records, find out the records in the failed state and timeout state, restore the context of the corresponding subtask, and retry. Please refer to Figure 1 , which shows a schematic diagram of the retry guarantee mechanism based on the state machine proposed in the embodiment of the present application. The business of configuring the retry guarantee mechanism is to deduct the virtual resources in the wallet and call the equity pool to issue equity. There may be three states in the specific execution task of this business, namely state 1 before deduction, state 2 after deduction, and state 3 after the equity is issued. According to the specific execution of the task, state 1, state 2 and state 3 are adaptively updated, and the retry guarantee logic will be triggered regularly through the scheduled task, so that it is found that a certain state may not be updated for a long time, and then the business is triggered to retry the subtask related to the state. If the retry is successful, the task can be executed successfully.
[0049] It can be seen that in the relevant technology, it is necessary to configure a corresponding retry backup mechanism for the business. With the increase of business and the increase of business concurrency, the redundancy of the retry backup mechanism will also increase significantly. Specifically, Figure 1The business in the system contains two types of logic, one is the business logic required to implement the business process, and the other is the retry logic designed to avoid execution failure. Business logic includes the logic of calling downstream (normal process) and the logic of restoring context to execute retry or fallback (abnormal process). The retry logic includes the logic of persisting state and context, and the logic of periodic polling query state and context. If multiple businesses are designed, each business includes its own retry logic, which obviously generates a lot of redundancy. The operating load of the business system composed of multiple businesses is increased, the operating resource usage is increased, and the generation of a large amount of redundancy also increases the operating risk of the business system and reduces the robustness of the business system.
[0050] The embodiment of the present application proposes that business logic is necessary to realize business, but retry logic is not. The latter is logic that is unrelated to specific business and can be extracted from the business to generate common components to achieve the technical purpose of high reuse and low coupling. Specifically, the embodiment of the present application provides a task execution method, which models the specific target task in the target business defined by the business component side as a DAG task flow that can be executed by calling the callback interface in sequence, and executes the target task by calling back the DAG task flow, thereby decoupling the business logic and the task execution logic. Each business component can register a callback with the target component in this application, so as to use the task flow service in the target component, which will call back the execution interface in the business component according to the specific target task, thereby managing the execution of the task, without the need for the business component developer to perform additional task management, and decoupling the business design and task execution. Each task maintains its corresponding retry record during the specific execution process without paying attention to the retry logic, because the retry records of each task will be traversed in the target component, and the relevant task flow instance will be retried when a retry is required, which completes the decoupling of the task execution logic and the retry logic. Developers of each business component and even developers of task execution logic do not need to worry about redesigning the retry logic. In other words, the task execution method of the present application realizes the three-way decoupling of business logic, task execution logic and retry backup logic, improves the success rate of task execution, and improves the robustness of equipment on the business side and task execution side.
[0051] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0052] Please refer to Figure 2 , which shows a schematic diagram of an application program running environment provided by an embodiment of the present application. The application program running environment may include: a terminal 10 and a server 20.
[0053] The terminal 10 includes, but is not limited to, electronic devices such as mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, game consoles, e-book readers, multimedia playback devices, wearable devices, etc. The terminal 10 may be installed with a client of an application program.
[0054] In an embodiment of the present application, the above-mentioned application can be any application that can provide or use task execution services. Typically, the application can be a payment application. Of course, in addition to payment applications, services that rely on task execution services can also be provided in other types of applications. For example, news applications, social applications, interactive entertainment applications, browser applications, shopping applications, content sharing applications, virtual reality (VR) applications, augmented reality (AR) applications, etc., are not limited to this in the embodiment of the present application. This is not limited in the embodiment of the present application. Optionally, a client of the above-mentioned application is running in the terminal 10.
[0055] The server 20 is used to provide background services for the client of the application in the terminal 10. For example, the server 20 can be the background server of the above application. The server 20 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Optionally, the server 20 provides background services for applications in multiple terminals 10 at the same time.
[0056] Optionally, the terminal 10 and the server 20 may communicate with each other via a network 30. The terminal 10 and the server 20 may be directly or indirectly connected via wired or wireless communication, which is not limited in the present application.
[0057] Please refer to Figure 3 , which shows a flowchart of a task execution method provided by an embodiment of the present application. The method can be applied to a computer device running the target component with the target component as a carrier. The above-mentioned computer device refers to an electronic device with data calculation and processing capabilities. For example, the execution subject of each step can be Figure 2 In the server 20 in the application running environment shown, the target component is a third-party component independent of the business component.
[0058] It is worth noting that the target component in the embodiment of the present application is a custom component and does not rely on mature commercial components in related technologies, such as zookeeper. The purpose of this processing is to achieve independent task management and retry mechanisms. It is not limited by zookeeper's own monitoring-control mechanism, but replaces zookeeper's own monitoring-control mechanism by self-designed decoupled task flow and retry logic, achieving the technical goal of high decoupling and higher robustness. ZooKeeper is a distributed, open source distributed application coordination service. It is a software that provides consistency services for distributed applications. The method may include the following steps:
[0059] S301. In response to a callback registration request sent by a business component, register at least one callback interface for a target business, the callback interface being used to trigger a call to a corresponding execution interface in the business component, the target business being a business associated with the business component.
[0060] The execution subject of the task execution method in the embodiment of the present application is the target component, which is a third-party component independent of the business component. The target component can accept the registration of the business component, and then execute the task corresponding to the target business corresponding to the business component. Specifically, the target component can concurrently execute multiple tasks of the target business, thereby providing concurrent service capabilities for the target business. For different businesses, each business can register with the target component, and then the target component can provide corresponding task execution services. In other words, the target component can provide concurrent service capabilities for multiple businesses, and this concurrent service capability refers to the execution capability of multiple tasks corresponding to the parallel execution business.
[0061] The aforementioned target business can be understood as any business. Taking the target business as the virtual rights issuance business as an example, multiple accounts can participate in the virtual rights issuance business. The issuance of virtual rights for each account can be abstracted as a task corresponding to the business. Issuing virtual rights to multiple accounts at the same time requires concurrent execution of multiple tasks of the business, and the target component of the embodiment of the present application can provide the ability to concurrently execute multiple tasks of the business.
[0062] In one embodiment, the above-mentioned response to the callback registration request issued by the above-mentioned business component, registering at least one callback interface for the target business, includes: in response to the callback registration request issued by the above-mentioned business component, calling the registration interface to register the corresponding task flow meta-information for each of the above-mentioned execution interfaces, and configuring the callback interface corresponding to the above-mentioned task flow meta-information; based on the identifiers corresponding to each of the above-mentioned task flow meta-information, and the identifier of the above-mentioned target business, determining a unique primary key, generating a registration record in a storage component, and returning the meta-information identifier corresponding to the above-mentioned registration record to the above-mentioned business component. The storage component is independent of the target component.
[0063] Please refer to Figure 4 , which shows the callback registration logic provided by the embodiment of the present application Figure 1 The business side (business component) can register callbacks to the target component through SDK calls. That is, the target component can encapsulate the relevant interfaces in the form of SDK and provide the SDK to the business side to facilitate the business side to register with the target component and use the services of the target component. The SDK encapsulates the logic for registering at least one callback interface for the target business. The function of this logic is Figure 4 In the figure, it is "Call SDK to register interface to register task flow". In the specific implementation process, the method name and handle related to the execution interface need to be registered in an independent module (service) in the target component, the callback interface needs to be registered with the remote procedure call framework trpc service, and the basic information of the callback interface and the target business needs to be recorded in another independent module (server). Independent modules such as service and server can store some information of the registration link so that the target component can use it when needed.
[0064] Please refer to Figure 5 , which shows the callback registration logic provided by the embodiment of the present application Figure 2 . The target component responds to the callback registration request and calls its own registration interface to register the corresponding task flow meta information for each of the above execution interfaces. The task flow meta information can be understood as the information corresponding to the execution interface. Through the task flow meta information, the execution interface can be finally called to complete the corresponding function. Please refer to the following table, which shows the correspondence between the task flow meta information and the execution interface in the virtual equity issuance business. The virtual equity issuance business can be implemented in two steps, which are: A. deducting the equity in the user's wallet; B. issuing the equity. Each step is encapsulated as an execution interface, namely Func1 and Func2. After successful registration, the target component can generate a corresponding task flow instance for each request that requires a virtual equity issuance business. After the specific business parameters are passed in, the task flow instance can execute the specific task of the business. The task flow uses callbacks to make Func1 and Func2 called in sequence to execute the specific task. In this link, Func1 and Func2 can also be considered to execute independent subtasks of the specific task.
[0065]
[0066] After the task flow meta-information is registered, the registration interface of the target component can feed back the identifiers corresponding to each task flow meta-information to the server. The server can determine the unique primary key based on the identifiers corresponding to each of the above task flow meta-information and the identifier of the above target business, and generate a registration record in the above storage component. Specifically, the "business name of the target business + task flow meta-information name" can be used as the unique key (unique primary key), the task flow meta-information can be saved in the storage component, and the meta-information id of successful registration is returned.
[0067] S302. In response to the target task execution request for the target business issued by the above-mentioned business component, the target task flow instance corresponding to the above-mentioned target task is obtained, the above-mentioned target task flow instance is triggered to create a corresponding retry record in the storage component, and the above-mentioned target task is executed by calling the above-mentioned callback interfaces of the above-mentioned target business, and any of the above-mentioned callback interfaces updates the above-mentioned retry record according to its own execution result; wherein the above-mentioned storage component is independent of the above-mentioned target component.
[0068] In the embodiment of this application, it is necessary to perform a retry based on the retry record, so the retry record should be stored in a safe storage space that is not affected by the task execution, so it is stored in a storage component independent of the above target component. The storage component can store three types of KV data, and redis, hbase, sos, etc. can be used. This application does not limit this. If a high-performance, high-availability storage component is used, the high availability of the retry logic can be further guaranteed.
[0069] In one embodiment, the storage component is used to record the correspondence between the request identifier and the execution identifier, the request identifier points to the request from the corresponding business component, and the execution identifier points to the task flow instance that responds to the request. The above-mentioned response to the target task execution request for the target business issued by the business component, obtaining the target task flow instance corresponding to the target task, includes: according to the request identifier of the target task execution request, querying the idempotent record in the storage component. In the case where the idempotent record does not exist, the following operations are performed: create the target task flow instance corresponding to the target task, and use the identifier of the target task flow instance as the target execution identifier; add a record indicating the correspondence between the request identifier of the target task execution request and the target execution identifier in the storage component. Of course, if the idempotent record exists, it means that there is already a target task flow instance corresponding to the target task execution request, and the target task execution request has taken effect, and no additional processing is required. In some embodiments, after the target task flow instance is generated, the distributed lock corresponding to the target task flow instance can also be obtained. Distributed lock is a lock mechanism used to solve concurrency problems in distributed systems. In a distributed system, each instance needs to compete for resources, and cannot use the built-in locks in a single machine multi-threaded system. Therefore, a lock mechanism that can cross microservices / cross virtual machines is needed, which is a distributed lock. In the embodiment of the present application, a corresponding distributed lock can be assigned to each task flow instance in a survival state to avoid concurrency problems.
[0070] In one embodiment, the storage component is used to record the corresponding relationship between the execution identifier and the execution information, and the execution information is the information generated during the execution of the corresponding task flow instance. The method further includes: after the target task flow instance is successfully executed, returning the execution result to the business component according to the execution information corresponding to the target task flow instance. In some embodiments, after the target task flow instance is successfully executed, the distributed lock corresponding to the target task flow instance can be released.
[0071] Please refer to Figure 6 , which shows a schematic diagram of the target task flow instance execution process provided by an embodiment of the present application. The following is a detailed description of the target task flow instance execution process using the virtual rights issuance (issuance of activity rewards) as an example in conjunction with the schematic diagram. When the business component obtains a request for a certain account for the target business (issuance of activity rewards), a target task execution request is generated, which carries a request id and specific business parameters, such as account information, timestamp information, activity party description information, etc. After the target component receives the target task execution request, it performs an idempotent record query based on the request id. If it exists, no processing is required. If it does not exist, the relevant interface is called to create a target task flow instance to specifically execute the activity reward issuance task for the aforementioned account.
[0072] After the target task flow instance is created, its corresponding execution id is generated, and an idempotent record is created according to the request id and the execution id, that is, the aforementioned step of adding a record indicating the correspondence between the request identifier of the target task execution request and the target execution identifier in the storage component is implemented. Simultaneously, an execution record needs to be created to record the correspondence between the execution identifier and the execution information. And a retry record needs to be created.
[0073] The target task flow instance acquires a distributed lock, and by calling back the previously registered interface of the business that issues the activity reward, it executes each subtask in sequence based on specific business parameters, and each subtask is executed through the corresponding callback interface. In some embodiments, the request id contains data information of the meta information id, which can facilitate the target component to quickly determine the business-related callback interface. According to the meta information id, the meta information of each task flow that executes the specific target task of issuing the activity reward can be queried, and the order in which the meta information of each task flow is called in sequence can also be queried, that is, the complete DAG task flow is queried, and the DAG task flow is called back in sequence until the task is completed.
[0074] According to the above, the specific task of issuing activity rewards can be divided into two subtasks, job1 and job2. Job1 and job2 are called sequentially until they succeed, and the distributed lock can be released after success. The information (execution information) generated by the execution process of job1 and job2 is updated in the execution record, which is stored in the storage component. At the same time, during the execution of each subtask, the execution result will be updated in the retry record so that it can be retried when an exception occurs, so as to improve the success rate of the target task execution.
[0075] S303. In the case that there is a target retry record that meets the preset conditions in the above storage component, determine the task flow instance to be retried corresponding to the above target retry record, and perform a retry operation on the above task flow instance to be retried.
[0076] In the embodiment of the present application, each business can access the target component through step S301, and then each concurrent specific task of each business will generate a retry record after step S302. For numerous retry records, the embodiment of the present application encapsulates the retry logic separately, that is, each retry record is uniformly processed through step S303, and the target retry record that meets the preset conditions is found by timing triggering step S303, and then the task flow instance to be retried corresponding to the above target retry record is determined, and the task flow instance to be retried is retried. Therefore, step S303 can also be understood as a centralized retry backup logic that is uniformly provided to each task under each business. In order to further achieve the purpose of decoupling the business from the retry bottom-up logic in the embodiment of the present application, the target component in the embodiment of the present application includes a task flow component and a retry component, and the above-mentioned task flow component is used to perform the following operations: in response to the callback registration request issued by the above-mentioned business component, register at least one callback interface for the target business; and, in response to the target task execution request for the above-mentioned target business issued by the above-mentioned business component, obtain the target task flow instance corresponding to the above-mentioned target task, the above-mentioned target task flow instance creates a corresponding retry record in the above-mentioned storage component, and executes the above-mentioned target task by calling each of the above-mentioned callback interfaces of the above-mentioned target business; the above-mentioned retry component is used to determine the task flow instance to be retried corresponding to the above-mentioned target retry record in the case where there is a target retry record that meets the preset conditions in the above-mentioned storage component, and retry the above-mentioned task flow instance to be retried. In short, the task flow component executes steps S301 and S302, and the retry component executes step S303.
[0077] In one embodiment, any of the above-mentioned callback interfaces updates the above-mentioned retry record according to its own execution result, including: generating a first retry record entry according to the above-mentioned callback interface's own execution result and the context data required for retrying the above-mentioned callback interface, and adding the above-mentioned first retry record entry to the above-mentioned retry record; the embodiment of the present application does not limit the context data, which can be understood as the data basis necessary for retrying, such as running stack information, storage location of important data required for retrying, entry of related functions, etc.
[0078] In the case that there is a target retry record that meets the preset conditions in the above-mentioned storage component, the task flow instance to be retried corresponding to the above-mentioned target retry record is determined, and before the retry operation is performed on the above-mentioned task flow instance to be retried, the above-mentioned method also includes: traversing each retry record in the above-mentioned storage component; for each of the above-mentioned retry records, if there is a target callback interface in the above-mentioned retry record, then the above-mentioned retry record is determined as the above-mentioned target retry record, and the above-mentioned target callback interface is a callback interface whose execution result indicates that it has not been successfully executed. The above-mentioned retry operation on the above-mentioned task flow instance to be retried includes: extracting the context data corresponding to the above-mentioned target callback interface in the above-mentioned target retry record, and resuming the execution of the above-mentioned task flow instance to be retried according to the context data corresponding to the above-mentioned target callback interface.
[0079] During the retry, a second retry record entry is generated according to the execution result corresponding to the target callback interface and the context data required for retrying the target callback interface, and the second retry record entry is added to the target retry record.
[0080] In some embodiments, the number of retries can also be limited. If the number of retries is too many, the retry is abandoned and the business component is directly notified that the task execution failed. In this case, the above-mentioned target callback interface is a callback interface whose execution result indicates that it has not been successfully executed, and the number of retries is less than the preset threshold. In some embodiments, the execution results of each callback interface are respectively recorded with the reasons for failure. For some reasons, the success rate of task execution can be improved by retrying, but for some reasons, it cannot. Therefore, it can also be decided whether to retry depending on the specific circumstances of the reason. That is, the above-mentioned target callback interface is a callback interface whose execution result indicates that it has not been successfully executed and the reason for the unsuccessful execution is a retryable reason, and the above-mentioned number of retries is less than the above-mentioned preset threshold.
[0081] If the target task flow instance mentioned above has an execution exception, a retry will also be triggered. In the case where the target task flow instance is the task flow instance to be retried, the retry operation on the task flow instance to be retried is as follows: obtaining the distributed lock corresponding to the target task flow instance; reading the context data corresponding to the target task flow instance; and resuming the execution of the target task flow instance according to the context data. Please refer to Figure 7, which shows a schematic diagram of the retry logic provided by an embodiment of the present application. This schematic diagram still takes the virtual equity issuance (issuance of activity rewards) as an example to embody the retry logic. In some virtual equity issuance businesses, there is a step of job3 after job2. If job2 is executed, but job3 executes abnormally, job3 can update its own execution result in the corresponding retry record. If an execution exception occurs, job3 can return two errors, a retryable error or a non-retryable error (fatal), which is determined by the returned error code. If it is a retryable error, the retry component can resume the execution of the target task flow instance to achieve the purpose of retry. Before retrying, it is necessary to first obtain a distributed lock, and then resume the execution of job3 after restoring the context required for execution. When job3 is executed, the execution record is still updated. If job3 is executed successfully, the execution record and the result indicating successful execution can be returned to the business party together, thereby improving the success rate of task execution.
[0082] The storage component in the embodiment of the present application can select a high-performance third-party storage component. The storage component can be used to store the following data. In the following table, id has the same meaning as identification.
[0083]
[0084] The retry component of the embodiment of the present application can be implemented based on a distributed timer, as long as the retry fallback logic can be triggered regularly, that is, the execution step S303 is triggered regularly. The present application does not limit the distributed timer. For example, a timer based on a delay queue, a timer based on a time wheel, and a timer based on Redis can all be used to build a retry component.
[0085] The task execution method of the embodiment of the present application registers the execution interface related to the target business in the business component in the business flow component. When a specific target task corresponding to the target business needs to be executed, a target task flow instance can be generated according to specific business parameters, and the target task flow instance calls back the relevant interface in turn in the form of a DAG task flow to complete the execution of the target task. So far, the embodiment of the present application has achieved the decoupling of the business logic design process and the task execution process. For concurrent task execution scenarios, there may be abnormal execution situations due to reasons such as the migration of distribution system service nodes. In order to improve the success rate of task execution, the embodiment of the present application encapsulates the retry logic. In other words, each task flow instance can store the execution results and related contexts of each subtask in its corresponding retry record when executing a specific task. The retry component will regularly traverse each retry record to select the task flow instance that needs to be retried to retry, and improve the execution success rate of the overall task by retrying.
[0086] Please refer to Figure 8, which shows a task execution diagram in an embodiment of the present application. Taking a certain business including three steps as an example, the specific task of the business requires three corresponding subtasks to be implemented, namely task 1, task 2, and task 3, and these three tasks are implemented by execution interface 1, execution interface 2, and execution interface 3, respectively. First, the execution interface related to the business is registered to obtain three callback interfaces, and the task flow component records the relevant task flow meta-information and returns the meta-information id. After the business party receives a specific request to execute the business, it can submit a task execution request to the task flow component based on the specific business data, the meta-information id, etc. The task flow component can execute the specific task through the callback interface and the specific business data, and feedback the execution result when the task is successful. If the execution fails, the retry component can also discover and retry in time.
[0087] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0088] Please refer to Fig. 9 , which shows a block diagram of a task execution device provided by an embodiment of the present application. The device is applied to a target component, which is a third-party component independent of a business component. The device has the function of implementing the above-mentioned task execution method, which can be implemented by hardware or by hardware executing corresponding software. The device can be a computer device or can be set in a computer device. The device can include:
[0089] The task flow processing module 901 is used to perform the following operations: in response to the callback registration request issued by the above-mentioned business component, register at least one callback interface for the target business, the above-mentioned callback interface is used to trigger the call of the corresponding execution interface in the above-mentioned business component, and the above-mentioned target business is the business associated with the above-mentioned business component; and, in response to the target task execution request for the above-mentioned target business issued by the above-mentioned business component, obtain the target task flow instance corresponding to the above-mentioned target task, trigger the above-mentioned target task flow instance to create a corresponding retry record in the storage component, and execute the above-mentioned target task by calling each of the above-mentioned callback interfaces of the above-mentioned target business, and any of the above-mentioned callback interfaces updates the above-mentioned retry record according to its own execution result; wherein the above-mentioned storage component is independent of the above-mentioned target component;
[0090] The retry module 902 is used to determine the task flow instance to be retried corresponding to the target retry record when there is a target retry record meeting the preset condition in the storage component, and perform a retry operation on the task flow instance to be retried.
[0091] The task flow processing module may be a task flow component in a target component, and the retry module may be a retry component in the target component.
[0092] In one embodiment, the retry module 902 is used to perform the following operations:
[0093] Generate a first retry record entry according to the execution result of the callback interface itself and the context data required for retrying the callback interface, and add the first retry record entry to the retry record;
[0094] Traversing each retry record in the storage component; for each retry record, if there is a target callback interface in the retry record, the retry record is determined to be the target retry record, and the target callback interface is a callback interface whose execution result indicates that it has not been successfully executed;
[0095] The above-mentioned retry operation on the above-mentioned task flow instance to be retried includes: extracting the context data corresponding to the above-mentioned target callback interface in the above-mentioned target retry record, and resuming the execution of the above-mentioned task flow instance to be retried according to the context data corresponding to the above-mentioned target callback interface.
[0096] In one embodiment, the target callback interface is a callback interface whose execution result indicates that it has not been successfully executed, and the number of retries is less than a preset threshold; or, the target callback interface is a callback interface whose execution result indicates that it has not been successfully executed and the reason for the unsuccessful execution is a retryable reason, and the number of retries is less than the preset threshold.
[0097] In one embodiment, the retry module 902 is used to perform the following operations:
[0098] A second retry record entry is generated according to the execution result corresponding to the target callback interface and the context data required for retrying the target callback interface, and the second retry record entry is added to the target retry record.
[0099] In one embodiment, the task flow component 901 is used to perform the following operations:
[0100] In response to the callback registration request sent by the business component, the registration interface is called to register the corresponding task flow meta information for each execution interface, and the callback interface corresponding to the task flow meta information is configured;
[0101] A unique primary key is determined based on the identifiers corresponding to the task flow meta-information and the identifier of the target business, a registration record is generated in the storage component, and the meta-information identifier corresponding to the registration record is returned to the business component.
[0102] In one embodiment, the storage component is used to record the correspondence between the request identifier and the execution identifier, the request identifier points to the request from the corresponding business component, the execution identifier points to the task flow instance that responds to the request, and the task flow component 901 is used to perform the following operations:
[0103] According to the request identifier of the target task execution request, query the idempotent record in the storage component;
[0104] If the above idempotent record does not exist, perform the following operations:
[0105] Create a target task flow instance corresponding to the target task, and use the identifier of the target task flow instance as the target execution identifier;
[0106] A record indicating the correspondence between the request identifier of the target task execution request and the target execution identifier is added to the storage component.
[0107] In one embodiment, the storage component is used to record the corresponding relationship between the execution identifier and the execution information, where the execution information is information generated during the execution of the corresponding task flow instance. The task flow component 901 is used to perform the following operations:
[0108] After the target task flow instance is successfully executed, the execution result is returned to the business component according to the execution information corresponding to the target task flow instance.
[0109] In one embodiment, when the target task flow instance is the task flow instance to be retried, the task flow component 901 is used to perform the following operations:
[0110] Read the context data corresponding to the target task flow instance;
[0111] Resume and execute the target task flow instance according to the context data.
[0112] In one embodiment, the target component includes a task flow component and a retry component, and the task flow component is used to perform the following operations:
[0113] In response to the callback registration request issued by the business component, register at least one callback interface for the target business; and, in response to the target task execution request issued by the business component for the target business, obtain the target task flow instance corresponding to the target task, the target task flow instance creates a corresponding retry record in the storage component, and executes the target task by calling each of the callback interfaces of the target business;
[0114] The retry component is used to determine the task flow instance to be retried corresponding to the target retry record when there is a target retry record that meets the preset conditions in the storage component, and to perform a retry operation on the task flow instance to be retried.
[0115] It should be noted that the device provided in the above embodiment, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0116] Please refer to Fig.10 , which shows a structural block diagram of a computer device provided by an embodiment of the present application. The computer device may be a server for executing the above-mentioned task execution method. Specifically:
[0117] The computer device 1000 includes a central processing unit (CPU) 1001, a system memory 1004 including a random access memory (RAM) 1002 and a read only memory (ROM) 1003, and a system bus 1005 connecting the system memory 1004 and the central processing unit 1001. The computer device 1000 also includes a basic input / output system (I / O (Input / Output) system) 1006 for facilitating information transmission between various components in the computer, and a large-capacity storage device 1007 for storing an operating system 1013, application programs 1014, and other program modules 1015.
[0118] The basic input / output system 1006 includes a display 1008 for displaying information and an input device 1009 such as a mouse and a keyboard for user inputting information. The display 1008 and the input device 1009 are connected to the central processing unit 1001 through an input / output controller 1010 connected to the system bus 1005. The basic input / output system 1006 may also include an input / output controller 1010 for receiving and processing inputs from a plurality of other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 1010 also provides output to a display screen, a printer, or other types of output devices.
[0119] The mass storage device 1007 is connected to the central processing unit 1001 through a mass storage controller (not shown) connected to the system bus 1005. The mass storage device 1007 and its associated computer readable medium provide non-volatile storage for the computer device 1000. That is, the mass storage device 1007 may include a computer readable medium (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.
[0120] Without loss of generality, computer readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read Only Memory), EEPROM (Electrically Erasable Programmable Read Only Memory), flash memory or other solid-state storage technologies, CD-ROM, DVD (Digital Video Disc) or other optical storage, cassettes, magnetic tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that computer storage media are not limited to the above. The above-mentioned system memory 1004 and mass storage device 1007 can be collectively referred to as memory.
[0121] According to various embodiments of the present application, the computer device 1000 can also be connected to a remote computer on the network through a network such as the Internet. That is, the computer device 1000 can be connected to the network 1012 through the network interface unit 1011 connected to the system bus 1005, or the network interface unit 1011 can be used to connect to other types of networks or remote computer systems (not shown).
[0122] The memory also includes a computer program, which is stored in the memory and configured to be executed by one or more processors to implement the task execution method.
[0123] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one instruction, at least one program, a code set or an instruction set is stored. When the at least one instruction, the at least one program, the code set or the instruction set is executed by a processor, the task execution method is implemented.
[0124] Specifically, the task execution method is applied to a target component, which is a third-party component independent of a business component, including:
[0125] In response to the callback registration request sent by the business component, register at least one callback interface for the target business, the callback interface is used to trigger the call of the corresponding execution interface in the business component, and the target business is the business associated with the business component;
[0126] In response to the target task execution request for the target business issued by the business component, a target task flow instance corresponding to the target task is obtained, the target task flow instance is triggered to create a corresponding retry record in the storage component, and the target task is executed by calling each of the callback interfaces of the target business, and any of the callback interfaces updates the retry record according to its own execution result; wherein the storage component is independent of the target component;
[0127] In the case that there is a target retry record that meets the preset conditions in the storage component, the task flow instance to be retried corresponding to the target retry record is determined, and a retry operation is performed on the task flow instance to be retried.
[0128] In one embodiment, any of the above callback interfaces updates the above retry record according to its own execution result, including: generating a first retry record entry according to the execution result of the above callback interface corresponding to itself and context data required for retrying the above callback interface, and adding the above first retry record entry to the above retry record;
[0129] In the case where there is a target retry record that meets the preset condition in the storage component, determining the task flow instance to be retried corresponding to the target retry record, and before retrying the task flow instance to be retried, the method further includes:
[0130] Traversing each retry record in the storage component; for each retry record, if there is a target callback interface in the retry record, the retry record is determined to be the target retry record, and the target callback interface is a callback interface whose execution result indicates that it has not been successfully executed;
[0131] The above-mentioned retry operation on the above-mentioned task flow instance to be retried includes: extracting the context data corresponding to the above-mentioned target callback interface in the above-mentioned target retry record, and resuming the execution of the above-mentioned task flow instance to be retried according to the context data corresponding to the above-mentioned target callback interface.
[0132] In one embodiment, the target callback interface is a callback interface whose execution result indicates that it has not been successfully executed, and the number of retries is less than a preset threshold; or, the target callback interface is a callback interface whose execution result indicates that it has not been successfully executed and the reason for the unsuccessful execution is a retryable reason, and the number of retries is less than the preset threshold.
[0133] In one embodiment, the above-mentioned resumption of execution of the above-mentioned task flow instance to be retried includes: generating a second retry record entry based on the self-execution result corresponding to the above-mentioned target callback interface and the context data required to retry the above-mentioned target callback interface, and adding the above-mentioned second retry record entry to the above-mentioned target retry record.
[0134] In one embodiment, registering at least one callback interface for the target service in response to the callback registration request issued by the service component includes:
[0135] In response to the callback registration request sent by the business component, the registration interface is called to register the corresponding task flow meta information for each execution interface, and the callback interface corresponding to the task flow meta information is configured;
[0136] A unique primary key is determined based on the identifiers corresponding to the task flow meta-information and the identifier of the target business, a registration record is generated in the storage component, and the meta-information identifier corresponding to the registration record is returned to the business component.
[0137] In one embodiment, the storage component is used to record the correspondence between the request identifier and the execution identifier, the request identifier points to the request from the corresponding business component, the execution identifier points to the task flow instance responding to the request, and the target task execution request for the target business issued in response to the business component is obtained to obtain the target task flow instance corresponding to the target task, including:
[0138] According to the request identifier of the target task execution request, query the idempotent record in the storage component;
[0139] If the above idempotent record does not exist, perform the following operations:
[0140] Create a target task flow instance corresponding to the target task, and use the identifier of the target task flow instance as the target execution identifier;
[0141] A record indicating the correspondence between the request identifier of the target task execution request and the target execution identifier is added to the storage component.
[0142] In one embodiment, the storage component is used to record the corresponding relationship between the execution identifier and the execution information, the execution information is the information generated during the execution of the corresponding task flow instance, and the method further includes:
[0143] After the target task flow instance is successfully executed, the execution result is returned to the business component according to the execution information corresponding to the target task flow instance.
[0144] In one embodiment, when the target task flow instance is the task flow instance to be retried, the retry operation is performed on the task flow instance to be retried:
[0145] Read the context data corresponding to the target task flow instance;
[0146] Resume and execute the target task flow instance according to the context data.
[0147] In one embodiment, the target component includes a task flow component and a retry component, and the task flow component is used to perform the following operations:
[0148] In response to the callback registration request issued by the business component, register at least one callback interface for the target business; and, in response to the target task execution request issued by the business component for the target business, obtain the target task flow instance corresponding to the target task, the target task flow instance creates a corresponding retry record in the storage component, and executes the target task by calling each of the callback interfaces of the target business;
[0149] The retry component is used to determine the task flow instance to be retried corresponding to the target retry record when there is a target retry record that meets the preset conditions in the storage component, and to perform a retry operation on the task flow instance to be retried.
[0150] Optionally, the computer-readable storage medium may include: ROM (Read Only Memory), RAM (Random Access Memory), SSD (Solid State Drives) or an optical disk, etc. Among them, the random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).
[0151] In an exemplary embodiment, a computer program product or a computer program is also provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the above-mentioned task execution method.
[0152] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In addition, the step numbers described in this article only illustrate a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application are not limited to this.
[0153] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0154] In addition, in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0155] The above are merely exemplary embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A task execution method, characterized in that: Applied to a target component, the target component being a third-party component independent of a business component, the method comprising: In response to a callback registration request issued by the business component, register at least one callback interface for a target business, wherein the callback interface is used to trigger a call to a corresponding execution interface in the business component, and the target business is a business associated with the business component; In response to a target task execution request for the target business issued by the business component, a target task flow instance corresponding to the target task is obtained, the target task flow instance is triggered to create a corresponding retry record in the storage component, and the target task is executed by calling each callback interface of the target business, and any callback interface updates the retry record according to its own execution result; wherein the storage component is independent of the target component; In the case that there is a target retry record that meets the preset condition in the storage component, the task flow instance to be retried corresponding to the target retry record is determined, and a retry operation is performed on the task flow instance to be retried.
2. The method according to claim 1, characterized in that Any of the callback interfaces updates the retry record according to its own execution result, including: generating a first retry record entry according to the execution result of the callback interface itself and context data required for retrying the callback interface, and adding the first retry record entry to the retry record; In the case where there is a target retry record that meets the preset condition in the storage component, determining the task flow instance to be retried corresponding to the target retry record, and before performing a retry operation on the task flow instance to be retried, the method further includes: Traversing each retry record in the storage component; for each retry record, if there is a target callback interface in the retry record, the retry record is determined to be the target retry record, and the target callback interface is a callback interface whose execution result indicates that it has not been successfully executed; The retrying operation on the task flow instance to be retried includes: extracting context data corresponding to the target callback interface in the target retry record, and resuming execution of the task flow instance to be retried according to the context data corresponding to the target callback interface.
3. The method according to claim 2, characterized in that The target callback interface is a callback interface whose execution result indicates that it has not been successfully executed, and the number of retries is less than a preset threshold; or, the target callback interface is a callback interface whose execution result indicates that it has not been successfully executed, the reason for the unsuccessful execution is a retryable reason, and the number of retries is less than the preset threshold.
4. The method according to claim 2, characterized in that: The resuming execution of the task flow instance to be retried includes: generating a second retry record entry according to the self-execution result corresponding to the target callback interface and the context data required for retrying the target callback interface, and adding the second retry record entry to the target retry record.
5. The method according to any one of claims 1 to 4, characterized in that: The step of registering at least one callback interface for a target service in response to a callback registration request issued by the service component includes: In response to the callback registration request sent by the business component, calling the registration interface to register the corresponding task flow meta information for each of the execution interfaces, and configuring the callback interface corresponding to the task flow meta information; A unique primary key is determined based on the identifiers corresponding to the task flow meta-information and the identifier of the target business, a registration record is generated in the storage component, and the meta-information identifier corresponding to the registration record is returned to the business component.
6. The method according to claim 5, characterized in that The storage component is used to record the correspondence between the request identifier and the execution identifier, the request identifier points to the request from the corresponding business component, the execution identifier points to the task flow instance responding to the request, and the target task execution request for the target business issued by the business component is obtained to obtain the target task flow instance corresponding to the target task, including: According to the request identifier of the target task execution request, query the idempotent record in the storage component; If the idempotent record does not exist, perform the following operations: Creating a target task flow instance corresponding to the target task, and using the identifier of the target task flow instance as a target execution identifier; A record indicating the correspondence between the request identifier of the target task execution request and the target execution identifier is added to the storage component.
7. The method according to claim 6, characterized in that The storage component is used to record the corresponding relationship between the execution identifier and the execution information, and the execution information is the information generated during the execution of the corresponding task flow instance. The method also includes: After the target task flow instance is successfully executed, an execution result is returned to the business component according to the execution information corresponding to the target task flow instance.
8. The method according to claim 7, characterized in that In the case where the target task flow instance is the task flow instance to be retried, the retry operation is performed on the task flow instance to be retried: Reading context data corresponding to the target task flow instance; The target task flow instance is resumed and executed according to the context data.
9. The method according to claim 1, characterized in that: The target component includes a task flow component and a retry component, and the task flow component is used to perform the following operations: In response to a callback registration request issued by the business component, register at least one callback interface for the target business; and, in response to a target task execution request issued by the business component for the target business, obtain a target task flow instance corresponding to the target task, the target task flow instance creates a corresponding retry record in the storage component, and executes the target task by calling each of the callback interfaces of the target business; The retry component is used to determine the task flow instance to be retried corresponding to the target retry record when there is a target retry record that meets the preset conditions in the storage component, and perform a retry operation on the task flow instance to be retried.
10. A task execution device, characterized in that: Applied to a target component, the target component is a third-party component independent of a business component, the device comprises: A task flow processing module, used to perform the following operations: in response to a callback registration request issued by the business component, register at least one callback interface for a target business, the callback interface is used to trigger the call of a corresponding execution interface in the business component, and the target business is a business associated with the business component; and, in response to a target task execution request for the target business issued by the business component, obtain a target task flow instance corresponding to the target task, trigger the target task flow instance to create a corresponding retry record in a storage component, and execute the target task by calling each of the callback interfaces of the target business, any of the callback interfaces updates the retry record according to its own execution result; wherein the storage component is independent of the target component; The retry module is used to determine the task flow instance to be retried corresponding to the target retry record when there is a target retry record that meets the preset conditions in the storage component, and perform a retry operation on the task flow instance to be retried.
11. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the task execution method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the task execution method as described in any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes to implement the task execution method as described in any one of claims 1 to 9.
Citation Information
Cited By
Method and system for repairing abnormal service data based on SDK (Software Development Kit)
CN120780531A
