A method, apparatus, device and medium for processing an asynchronous task
Patent Information
- Application Number
- CN202211505590.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-28
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2042-11-28
AI Technical Summary
[0003]鉴于以上所述现有技术的缺点,本发明提供一种异步任务的处理方法,以解决上述异步任务的处理过程常通过中间件技术实现,但是中间件与业务系统的耦合程度高,不利于业务系统的运行维护和升级开发的问题
[0038] The beneficial effects of this invention are as follows: This invention manages the calling logic of interface functions in a task-oriented manner and generates an asynchronous task management component. The asynchronous task management component can be widely introduced into any business system that needs it. At the same time, the asynchronous task management component does not depend on other components, implements the functions of adding tasks and retrying tasks on its own, and provides a unified management and compensation mechanism for asynchronous tasks. The processing of asynchronous tasks by the asynchronous task management component decouples it from the business system and improves the processing efficiency of asynchronous tasks.
Smart Images

Figure CN115756802B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, specifically to a method, apparatus, device, and medium for processing asynchronous tasks. Background Technology
[0002] With the advent of the cloud computing and big data era, cloud service systems are becoming increasingly complex. In internal system function interface calls or interactions with other systems, some interface function processes involve numerous processing nodes and long processing times, making real-time calls insufficient to meet system efficiency requirements. Asynchronous processing can be used to solve process blocking issues caused by excessively long processing times at certain business nodes. For example, initiating operation notifications or data synchronization between systems often doesn't require waiting for the interface function's result; only the final success of the business operation is needed. Asynchronous task processing is often implemented using middleware technology; however, the high degree of coupling between middleware and business systems is detrimental to the operation, maintenance, and upgrade development of business systems. Summary of the Invention
[0003] In view of the shortcomings of the prior art described above, the present invention provides a method for processing asynchronous tasks to solve the problem that the processing of asynchronous tasks is often implemented through middleware technology, but the middleware is highly coupled with the business system, which is not conducive to the operation, maintenance and upgrade development of the business system.
[0004] This invention provides a method for processing asynchronous tasks, the method comprising:
[0005] Obtain attribute information and business logic information of multiple asynchronous tasks from multiple business systems;
[0006] By inheriting the attribute information and business logic information of multiple asynchronous tasks, information about multiple target tasks and multiple task processors can be obtained.
[0007] Obtain information about the task processor factory, the task management module, and the asynchronous task management table;
[0008] The information of multiple target tasks, multiple task processors, task processor factory, task management module, and asynchronous task management table are packaged to obtain an asynchronous task management component.
[0009] Integrate the asynchronous task management component into the pending business system, define the asynchronous tasks in the pending business system, and obtain multiple asynchronous tasks; and
[0010] By invoking information from the task management module, multiple asynchronous tasks are added to the asynchronous task management component, and multiple task processors process the multiple asynchronous tasks.
[0011] In one embodiment of the present invention, processing the asynchronous task to be processed by a plurality of processors further includes the following steps:
[0012] Get information from the task addition module and the task retry module;
[0013] The information of the task addition function module is invoked to add the information of the asynchronous task to the asynchronous task management component, and the information of the processor that matches the asynchronous task is obtained.
[0014] In one embodiment of the present invention, processing the asynchronous task to be processed by a plurality of processors further includes the following steps:
[0015] Determine whether the asynchronous task has been successfully processed by the task processor. If the asynchronous task has been successfully processed by the task processor, obtain the successful processing result of the asynchronous task. If the asynchronous task has not been successfully processed by the task processor, save the asynchronous task to the asynchronous task management table of the asynchronous task management component, and perform a compensatory retry on the asynchronous task according to the information of the task retry function module.
[0016] In one embodiment of the present invention, the asynchronous task processing method further includes the following steps:
[0017] Obtain information about multiple business processors and multiple asynchronous tasks within the business system;
[0018] The information of multiple business processors and multiple asynchronous tasks is stored in the asynchronous task management component, and the information of multiple task processors and multiple target tasks in the asynchronous task management component is obtained.
[0019] In one embodiment of the present invention, the asynchronous task processing method further includes the following steps:
[0020] Obtain the functional information of the task processor;
[0021] Based on the functional information of the task processors, multiple task processors and multiple target tasks are bound together.
[0022] In one embodiment of the present invention, the asynchronous task processing method further includes the following steps:
[0023] The asynchronous task management component is integrated into the pending business system, and the information of the target task and the task processor of the asynchronous task management component are obtained.
[0024] In one embodiment of the present invention, the following steps are further included:
[0025] Based on the information of the target task and the information of the task processor, define the asynchronous task and the business processor, and obtain the information of the asynchronous task and the business processor in the business system to be processed;
[0026] According to the interface call function of the business processor, the business system to be processed calls the asynchronous task management component to process the asynchronous task.
[0027] This invention provides an asynchronous task processing apparatus, the apparatus comprising:
[0028] The task information acquisition module is used to acquire attribute information and business logic information of multiple asynchronous tasks from multiple business systems.
[0029] The target task acquisition module is used to acquire information about multiple target tasks and multiple processors by inheriting the attribute information and business logic information of multiple asynchronous tasks.
[0030] The task management information acquisition module is used to acquire information about the task processor factory, the task management module, and the asynchronous task management table.
[0031] The component acquisition module is used to package information of multiple target tasks, information of multiple processors, information of the task processor factory, information of the task management module, and information of the asynchronous task management table to acquire the asynchronous task management component.
[0032] An asynchronous task acquisition module is used to integrate the asynchronous task management component into the pending business system, complete the definition of the asynchronous tasks by the pending business system, and acquire multiple asynchronous tasks; and
[0033] The task processing module is used to add multiple asynchronous tasks to the asynchronous task management component by calling information from the task management module, and the multiple processors process the multiple asynchronous tasks.
[0034] The present invention provides an electronic device, the electronic device comprising:
[0035] At least one processor;
[0036] A storage device for storing at least one program, which, when executed by the at least one processor, causes the electronic device to implement the asynchronous task processing method of any of the above.
[0037] The present invention provides a computer-readable storage medium, characterized in that it stores a computer program thereon, which, when executed by a computer processor, causes the computer to perform the asynchronous task processing method described in any of the preceding claims.
[0038] The beneficial effects of this invention are as follows: This invention manages the calling logic of interface functions in a task-oriented manner and generates an asynchronous task management component. The asynchronous task management component can be widely introduced into any business system that needs it. At the same time, the asynchronous task management component does not depend on other components, implements the functions of adding tasks and retrying tasks on its own, and provides a unified management and compensation mechanism for asynchronous tasks. The processing of asynchronous tasks by the asynchronous task management component decouples it from the business system and improves the processing efficiency of asynchronous tasks.
[0039] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0040] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:
[0041] Figure 1 This is a schematic diagram illustrating the application environment of an asynchronous task processing method according to an exemplary embodiment of this application;
[0042] Figure 2 This is a flowchart illustrating an asynchronous task processing method according to an exemplary embodiment of this application;
[0043] Figure 3 This is a flowchart illustrating another method for asynchronous task processing, as shown in an exemplary embodiment of this application;
[0044] Figure 4 This is a flowchart illustrating the operation method of a task processor factory as shown in an exemplary embodiment of this application;
[0045] Figure 5 This is a flowchart illustrating a method by which an asynchronous task management component is invoked by a business system, as shown in an exemplary embodiment of this application.
[0046] Figure 6 This is a schematic diagram illustrating the structure of an asynchronous task processing apparatus according to an exemplary embodiment of this application.
[0047] Figure 7A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Detailed Implementation
[0048] The embodiments of the present invention will be described below with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention and not for limiting the scope of protection of the present invention.
[0049] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0050] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the invention. However, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the invention.
[0051] First, it's important to clarify that synchronous tasks mean only one task can be executed at a time. If there are multiple tasks, they must be executed in a queue; that is, the next task will only be executed after the previous one is completed. The execution order of the tasks is consistent with their listed order; they are synchronous. Asynchronous tasks, on the other hand, mean that each task has one or more callback functions. After the previous task finishes, the callback function is executed first, not the next task. The next task begins execution without waiting for the previous task to finish. Therefore, the execution order of the tasks is inconsistent with their listed order; they are asynchronous.
[0052] The essence of a Maven repository is an advanced project management tool that abstracts the project development and management process into a Project Object Model (POM). Maven repositories are cross-platform, meaning they are compatible with Windows, Linux, and macOS. Therefore, when using Maven repositories, developers only need to make some simple configurations on different operating systems to batch complete project builds and generate reports and documentation.
[0053] Figure 1 This is a schematic diagram illustrating the application environment of an asynchronous task processing method, as shown in an exemplary embodiment of this application. For example... Figure 1 As shown, in some embodiments, user 110 triggers multiple services through the business system in business system module 120. After obtaining the triggered multiple services, business system module 120 calls the task addition function module in asynchronous task processing module 130 to add the triggered multiple tasks to asynchronous task processing module 130. The triggered multiple services match the target tasks preset in asynchronous task processing module 130, and the processor corresponding to the target task performs business logic processing, and transmits the processing results of the multiple services to business system module 120. User 110 obtains the processing results of the triggered multiple services according to business system module 120. The embodiments of this application do not limit the specific function of asynchronous task acquisition module 130. Figure 1 The asynchronous task acquisition module 130 shown can be, for example, an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. No limitation is imposed here. Data exchange between the business system module 120 and the asynchronous task processing module 130 can be performed via wireless networks such as 3G (third-generation mobile information technology), 4G (fourth-generation mobile information technology), and 5G (fifth-generation mobile information technology). The embodiments of this application do not limit this and can be configured according to actual needs.
[0054] In some embodiments, the processing of asynchronous tasks is often implemented through middleware technology. However, the high degree of coupling between middleware and business systems is detrimental to the operation, maintenance, and upgrade development of business systems. To address these issues, embodiments of this application propose a method, apparatus, device, and medium for processing asynchronous tasks, which will be described in detail below.
[0055] Please see Figure 2 , Figure 2 This is a flowchart illustrating an exemplary embodiment of an asynchronous task processing method according to this application. In some embodiments, this method can be applied to... Figure 1 The implementation environment shown is specifically executed by the asynchronous task processing module 130 within that implementation environment. It should be understood that this method can also be applied to other exemplary implementation environments and executed by devices in other implementation environments; this embodiment does not limit the implementation environment to which the method is applicable.
[0056] For example, the asynchronous task processing module 130 to which the asynchronous task processing method disclosed in this embodiment is applicable may be equipped with an SDK (Software Development Kit, which is a collection of development tools for building application software for specific software packages, software frameworks, operating systems, etc.) and Maven. The method disclosed in this embodiment is specifically implemented as one or more functions provided by Maven.
[0057] like Figure 2 As shown, in an exemplary embodiment, the method for processing asynchronous tasks includes at least steps S210 to S260, which are described in detail below:
[0058] Step S210: Obtain attribute information and business logic information of multiple asynchronous tasks from multiple business systems;
[0059] First, it should be noted that the attributes of asynchronous tasks across multiple business systems include a business serial number and a target class. The business serial number is a business identifier generated by the business system, such as Business 1, Business 2, and Business 3, ensuring the uniqueness of the asynchronous task within each business system. The target class is a generic class representing an entity class of business data, set by the business system. The business logic information of the asynchronous task refers to the processing logic steps for that asynchronous task.
[0060] Step S220: By inheriting the attribute information and business logic information of multiple asynchronous tasks, information of multiple target tasks and information of multiple task processors are obtained.
[0061] In one embodiment of this application, by inheriting the attribute information and business logic information of asynchronous tasks in all business systems, the asynchronous task component generates target task information based on the attribute information of the asynchronous task and obtains task processor information based on the business logic information. The task processor provides two methods to be implemented: a method for implementing business logic and a method for obtaining the target task.
[0062] Step S230: Obtain information about the task processor factory, the task management module, and the asynchronous task management table;
[0063] In one embodiment of this application, the task processor factory binds a target task to a processor that matches the target task. This facilitates matching the target task with the asynchronous task when the asynchronous task management component is invoked, and obtaining the processor that matches the target task through the target task. The task management module includes a task addition module and a task retry module. The task addition module has two parameters: a target task instance and a processor name. The task addition module adds asynchronous tasks from the business system to the asynchronous task management component when the business system invokes the component. The task retry module is used to re-add the asynchronous task from the business system and re-process it if an exception or failure occurs during the processing of the target task by the processor, thus achieving a compensatory retry.
[0064] Step S240: Package the information of multiple target tasks, multiple task processors, task processor factory, task management module, and asynchronous task management table to obtain the asynchronous task management component.
[0065] In one embodiment of this application, information about multiple target tasks, multiple task processors, task processor factories, task management modules, and asynchronous task management tables of the asynchronous task management component are packaged and uploaded to a Maven repository to generate a Maven dependency package, which is the asynchronous task management component. In the Maven project management used in this application, the asynchronous task management component can also be generated using tools such as SDK toolkits.
[0066] Step S250: Integrate the asynchronous task management component into the business system to be processed, and according to the asynchronous task management component, the business system to be processed completes the definition of asynchronous tasks and obtains multiple asynchronous tasks.
[0067] In one embodiment of this application, the pending business system integrates the asynchronous task management component by depending on or importing a dependency package. When the pending business system calls the asynchronous task management component, it first needs to define the asynchronous task and the business processor. The asynchronous task inherits the attribute information of the target task provided by the asynchronous task management component, and based on the attribute information of the target task, the business system sets the business serial number and business entity data of the asynchronous task. The business processor implements a unified interface for calling the asynchronous task management component, and its business implementation method is a method for completing business logic and calling external interfaces.
[0068] Step S260: By calling the information from the task management module, the asynchronous task is added to the asynchronous task management component, and then the asynchronous task is processed by multiple task processors.
[0069] In one embodiment of this application, based on the unified interface of multiple asynchronous tasks in the pending business system and the asynchronous task management component, the pending business system calls the interface of the asynchronous task management component through a business processor to invoke the task addition function module in the task management module, and adds multiple asynchronous tasks to the asynchronous task management component. The asynchronous task management component locates the task processor bound to the target task based on the multiple asynchronous tasks. It processes the multiple asynchronous tasks by calling the business logic functions in the task processor. After the asynchronous task management component obtains the processing result of the asynchronous task, it transmits the processing result to the pending business system through the interface. Once the pending business system obtains the processing result of the asynchronous task, the processing of the asynchronous task is complete.
[0070] Figure 3 This is a flowchart illustrating another method for asynchronous task processing, as shown in an exemplary embodiment of this application. Figure 3 As shown, in an exemplary embodiment, another method for asynchronous task processing includes at least steps S310 to S342, which are described in detail below:
[0071] Step S310: Obtain information from the task addition function module and the task retry function module.
[0072] In one embodiment of this application, the task management module includes a task addition module and a task retry module. The task addition module takes two parameters: a target task instance and a processor name. The task addition module adds asynchronous tasks from the business system to the asynchronous task management component when the business system calls the component. The task retry module, when processing a target task through the processor, requests the addition of the asynchronous task from the business system and reprocesses it if an exception or failure occurs, thus achieving a compensatory retry.
[0073] Step S320: Obtain information about the asynchronous task.
[0074] In one embodiment of this application, the information of the asynchronous task includes a business serial number and a target class, wherein the target class is business entity data.
[0075] Step S330: Invoke the information of the task addition function module, add the information of the asynchronous task to the asynchronous task management component, and obtain the information of the task processor that matches the asynchronous task.
[0076] In one embodiment of this application, the business system adds asynchronous tasks to the asynchronous task management component by invoking the task addition function module in the task management module. The task addition function module locates the task processor bound to the target task based on the asynchronous task.
[0077] Step S340: Determine whether the asynchronous task has been successfully processed by the task processor.
[0078] In one embodiment of this application, the task processor processes the asynchronous task by calling business logic, and then determines whether the asynchronous task has been successfully processed by the processor. If the asynchronous task has been successfully processed by the task processor, step S341 is executed. If the asynchronous task has not been successfully processed by the task processor, that is, an exception or failure occurs during the processing, step S342 is executed.
[0079] Step S341: Obtain the successful processing result of the asynchronous task to be processed.
[0080] In one embodiment of this application, after successfully processing the asynchronous task to be processed, the asynchronous task management component transmits the successful processing result of the asynchronous task to the business system.
[0081] Step S342: Save the asynchronous task to the asynchronous task management table of the asynchronous task management component, and perform compensation retries on the asynchronous task based on the information from the task retry function module.
[0082] In one embodiment of this application, if an asynchronous task encounters a processing exception or fails during processing by the task processor, the asynchronous task management component saves the failed asynchronous task in the asynchronous task management table, awaiting compensation and retrying by the task retry function module. If the retry fails, the number of failures is changed. A default number of retryes can be set for each task when recording tasks. The system can also provide a backend management page for the failed task data, allowing for configurable adjustments to the content of target tasks in the asynchronous task management component, such as the number of times a task can be invoked, task status, etc. It also allows for configuring scheduled tasks in the task table and flexible configuration management of failed tasks.
[0083] Figure 4 This is a flowchart illustrating the operation method of a task processor factory, as shown in an exemplary embodiment of this application. Figure 4 As shown, in an exemplary embodiment, the working method of the task processor factory includes at least steps S410 to S420, which are detailed below:
[0084] Step S410: Obtain information about multiple business processors and multiple asynchronous tasks of the business system.
[0085] In one embodiment of this application, the information of multiple business processors implemented by the business system is the business logic required to implement asynchronous tasks and the information of calling interfaces.
[0086] Step S420: Store the information of multiple business processors and multiple asynchronous tasks in the asynchronous task management component, and obtain the information of multiple task processors and multiple target tasks in the asynchronous task management component.
[0087] In one embodiment of this application, when the business system integrates the asynchronous task management component, the business processor factory stores the information of multiple business processors and the information of multiple asynchronous tasks into the asynchronous task management component when the business system starts, obtains the target tasks corresponding to all task processors in the component, and performs cyclic processing on each task processor.
[0088] Step S430: Obtain the functional information of the task processor.
[0089] Step S440: Bind multiple task processors and multiple target tasks according to the function information of the task processors.
[0090] In one embodiment of this application, the target task and the task processor are bound together by obtaining the functional information of the target task from the task processor. This makes it convenient for the asynchronous task management component to obtain the corresponding task processor based on the task entity of the asynchronous task passed in by the interface when it is called, according to the business logic.
[0091] Figure 5 This is a flowchart illustrating a method in which an asynchronous task management component is invoked by a business system, as shown in an exemplary embodiment of this application. Figure 5 As shown, in an exemplary embodiment, the method by which the asynchronous task management component is invoked by the business system includes at least steps S510 to S530, which are detailed below:
[0092] Step S510: Integrate the asynchronous task management component into the business system to be processed, and obtain the target task information and task processor information of the asynchronous task management component.
[0093] In one embodiment of this application, the business system to be processed integrates the asynchronous task management component into the business system by relying on or importing dependency packages.
[0094] Step S520: Define asynchronous tasks and business processors based on the information of the target task and the information of the task processor, and obtain the information of asynchronous tasks and business processors in the business system to be processed.
[0095] In one embodiment of this application, when a business system calls the asynchronous task management component, the business system first needs to define the asynchronous task and the business processor. The asynchronous task inherits the attribute information of the target task provided by the asynchronous task management component, and based on the attribute information of the target task, the business system sets the business serial number and business entity data of the asynchronous task. The business processor implements the unified interface for calling the asynchronous task management component, and the business implementation method of the task processor is to complete the business logic or the calling method of the external interface.
[0096] In step S530, the business system to be processed calls the asynchronous task management component to process the asynchronous task through the interface call function of the business processor.
[0097] The pending business system calls the task addition function module provided by the asynchronous task management component to hand over the defined asynchronous task to the asynchronous task management component. The task addition function module of the asynchronous task management component completes the location of the task processor and calls the business logic method in the task processor to process the asynchronous task.
[0098] Figure 6 This is a schematic diagram illustrating the structure of an asynchronous task processing apparatus according to an exemplary embodiment of this application. This apparatus can be applied to... Figure 1 The device is illustrated in the application environment shown and is specifically configured in the asynchronous task processing module 130. This device can also be applied to other exemplary implementation environments and specifically configured in other devices; this embodiment does not limit the implementation environment to which the device is applicable.
[0099] like Figure 6 As shown, the exemplary data security storage device includes:
[0100] The task information acquisition module 610 is used to acquire attribute information and business logic information of multiple asynchronous tasks from multiple business systems; the target task acquisition module 620 is used to acquire information of multiple target tasks and multiple task processors by inheriting the attribute information and business logic information of multiple asynchronous tasks; the task management information acquisition module 630 is used to acquire information of task processor factories, task management modules, and asynchronous task management tables; the component acquisition module 640 is used to package the information of multiple target tasks, multiple task processors, task processor factories, task management modules, and asynchronous task management tables to acquire an asynchronous task management component; the asynchronous task acquisition module 650 is used to integrate the asynchronous task management component into the business system to be processed and complete the definition of asynchronous tasks in the business system to be processed, acquiring multiple asynchronous tasks; and the task processing module 660 is used to add multiple asynchronous tasks to the asynchronous task management component by calling the information of the task management module, and multiple task processors process multiple asynchronous tasks.
[0101] Figure 7 A schematic diagram of a computer system suitable for implementing the embodiments of this application is shown. It should be noted that... Figure 7 The computer system 700 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0102] like Figure 7 As shown, the computer system 700 includes a Central Processing Unit (CPU) 701, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 702 or programs loaded from storage portion 708 into Random Access Memory (RAM) 703, such as performing the methods described in the above embodiments. The RAM 703 also stores various programs and data required for system operation. The CPU 701, ROM 702, and RAM 703 are interconnected via a bus 704. An Input / Output (I / O) interface 705 is also connected to the bus 704.
[0103] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, mouse, etc.; an output section 707 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 710 as needed so that computer programs read from it can be installed into the storage section 708 as needed.
[0104] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 709, and / or installed from removable medium 711. When the computer program is executed by central processing unit (CPU) 701, it performs various functions defined in the system of this application.
[0105] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0106] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0107] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.
[0108] Another aspect of this application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer's processor, causes the computer to perform the processing method for the asynchronous task as described above. This computer-readable storage medium may be included in the electronic device described in the above embodiments, or it may exist independently and not assembled into the electronic device.
[0109] Another aspect of this application provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the asynchronous task processing method provided in the various embodiments described above.
[0110] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.
Claims
1. A method for processing asynchronous tasks, characterized in that, The method includes: Obtain attribute information and business logic information of multiple asynchronous tasks from multiple business systems; By inheriting the attribute information and business logic information of multiple asynchronous tasks, information about multiple target tasks and multiple task processors can be obtained. Obtain information about the task processor factory, the task management module, and the asynchronous task management table; The information of multiple target tasks, multiple task processors, task processor factory, task management module, and asynchronous task management table are packaged to obtain an asynchronous task management component. Based on the information of the target task and the information of the task processor, the asynchronous task and the business processor are defined, and the information of the asynchronous task and the business processor in the business system to be processed is obtained; according to the interface call function of the business processor, the business system to be processed calls the asynchronous task management component to process the asynchronous task; Integrate the asynchronous task management component into the pending business system, define the asynchronous tasks in the pending business system, and obtain multiple asynchronous tasks; and By calling the information from the task management module, multiple asynchronous tasks are added to the asynchronous task management component, and multiple task processors process the multiple asynchronous tasks.
2. The asynchronous task processing method according to claim 1, characterized in that, Processing the asynchronous task to be processed by multiple processors further includes the following steps: Get information from the task addition module and the task retry module; The information of the task addition function module is invoked to add the information of the asynchronous task to the asynchronous task management component, and the information of the processor that matches the asynchronous task is obtained.
3. The asynchronous task processing method according to claim 2, characterized in that, Processing the asynchronous task to be processed by multiple processors further includes the following steps: Determine whether the asynchronous task has been successfully processed by the task processor. If the asynchronous task has been successfully processed by the task processor, obtain the successful processing result of the asynchronous task. If the asynchronous task has not been successfully processed by the task processor, save the asynchronous task to the asynchronous task management table of the asynchronous task management component, and perform a compensatory retry on the asynchronous task according to the information of the task retry function module.
4. The asynchronous task processing method according to claim 1, characterized in that, It also includes the following steps: Obtain information about multiple business processors and multiple asynchronous tasks within the business system; The information of multiple business processors and multiple asynchronous tasks is stored in the asynchronous task management component, and the information of multiple task processors and multiple target tasks in the asynchronous task management component is obtained.
5. The asynchronous task processing method according to claim 4, characterized in that, It also includes the following steps: Obtain the functional information of the task processor; Based on the functional information of the processor, multiple task processors and multiple target tasks are bound together.
6. The asynchronous task processing method according to claim 1, characterized in that, It also includes the following steps: The asynchronous task management component is integrated into the pending business system, and the information of the target task and the task processor of the asynchronous task management component are obtained.
7. An asynchronous task processing apparatus, characterized in that, The device includes: The task information acquisition module is used to acquire attribute information and business logic information of multiple asynchronous tasks from multiple business systems. The target task acquisition module is used to acquire information about multiple target tasks and multiple task processors by inheriting the attribute information and business logic information of multiple asynchronous tasks. The task management information acquisition module is used to acquire information about the task processor factory, the task management module, and the asynchronous task management table. The component acquisition module is used to package information of multiple target tasks, information of multiple task processors, information of the task processor factory, information of the task management module, and information of the asynchronous task management table to acquire the asynchronous task management component. The component acquisition module is further configured to: define the asynchronous task and the business processor according to the information of the target task and the information of the task processor; acquire the information of the asynchronous task and the business processor in the business system to be processed; and, according to the interface call function of the business processor, call the asynchronous task management component to process the asynchronous task. An asynchronous task acquisition module is used to integrate the asynchronous task management component into the pending business system, complete the definition of the asynchronous tasks by the pending business system, and acquire multiple asynchronous tasks; and The task processing module is used to add multiple asynchronous tasks to the asynchronous task management component by calling information from the task management module, and the multiple task processors process the multiple asynchronous tasks.
8. An electronic device, the electronic device comprising: At least one processor; A storage device for storing at least one program, which, when executed by the at least one processor, causes the electronic device to implement the asynchronous task processing method of any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by the computer's processor, causes the computer to perform the asynchronous task processing method of any one of claims 1 to 6.
Citation Information
Patent Citations
Software construction method and device, computer equipment and storage medium
CN113760296A