Task processing methods, apparatus, non-volatile storage media, and electronic devices

By intercepting task request information and generating asynchronous polling tasks in a microservice architecture, the high thread resource requirements and low efficiency caused by synchronous processing are solved, achieving efficient task processing conversion and optimized resource utilization.

CN115827195BActive Publication Date: 2026-11-17INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211462718.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-21
Publication Date
2026-11-17
Estimated Expiration
2042-11-21

AI Technical Summary

Technical Problem

In microservice architectures, synchronous processing consumes threads, leading to high thread resource requirements and low processing efficiency, and existing technologies have not been able to effectively solve this problem.

Method used

By intercepting task request information from upstream servers to downstream servers, generating asynchronous polling tasks and monitoring the execution thread status, releasing task request information, and continuing until the execution thread completes, synchronous-to-asynchronous processing is achieved.

Benefits of technology

It reduces task processing time, improves processing efficiency and thread utilization, and enhances task processing capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115827195B_ABST
    Figure CN115827195B_ABST
Patent Text Reader

Abstract

This application discloses a task processing method, apparatus, non-volatile storage medium, and electronic device. Relating to the field of big data, the method includes: intercepting task request information sent from an upstream server to a downstream server, wherein the upstream server converts application requirements into task request information, and the downstream server processes the application requirements corresponding to the task request information; determining an execution thread for processing by the downstream server based on the task request information; if the execution thread is determined to be in an incomplete execution state, generating a first-round polling task corresponding to the execution thread and releasing the task request information; if the first-round polling task finds that the execution thread is in a completed execution state, sending the target processing result corresponding to the task request information to the upstream server. This application solves the problem in related technologies where synchronous processing occupies threads, leading to high thread resource requirements and low processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud computing, and more specifically, to a task processing method, apparatus, non-volatile storage medium, and electronic device. Background Technology

[0002] Faced with the challenge of ever-increasing access volumes, when processing application demands synchronously, the service processing time of one node in the chain is often long. This affects the processing time of other upstream servers calling that node, increasing the processing time and causing long call wait times. Consequently, limited server thread resources cannot be released in time to be reused for other tasks, resulting in a decrease in overall resource utilization. Related technologies alleviate the shortage of thread resources by providing more threads, but this comes at the cost of increased equipment procurement and management costs.

[0003] There is currently no effective solution to the problem of high thread resource requirements and low processing efficiency caused by synchronous processing occupying threads in related technologies. Summary of the Invention

[0004] The main objective of this application is to provide a task processing method, apparatus, non-volatile storage medium, and electronic device to solve the problem in related technologies where synchronous processing occupies threads, resulting in high thread resource requirements and low processing efficiency.

[0005] To achieve the above objectives, according to one aspect of this application, a task processing method is provided. The method includes: intercepting task request information sent from an upstream server to a downstream server, wherein the upstream server is used to convert application requirements into the task request information, and the downstream server is used to process the application requirements corresponding to the task request information; determining an execution thread for the downstream server to perform processing based on the task request information; if it is determined that the execution thread is in an incomplete execution state, generating a first polling task corresponding to the execution thread and releasing the task request information, wherein the first polling task is used to monitor the execution state of the execution thread in real time; and if the first polling task finds that the execution thread is in a completed execution state, sending the target processing result corresponding to the task request information to the upstream server.

[0006] To achieve the above objectives, according to another aspect of this application, a task processing apparatus is provided. The apparatus includes: an interception module for intercepting task request information sent from an upstream server to a downstream server, wherein the upstream server is used to convert application requirements into the task request information, and the downstream server is used to process the application requirements corresponding to the task request information; a determination module for determining an execution thread for the downstream server to perform processing based on the task request information; a generation module for generating a first polling task corresponding to the execution thread and releasing the task request information when it is determined that the execution thread is in an incomplete execution state, wherein the first polling task is used to monitor the execution state of the execution thread in real time; and a sending module for sending the target processing result corresponding to the task request information to the upstream server when the first polling task finds that the execution thread is in a completed execution state.

[0007] To achieve the above objectives, according to another aspect of this application, a non-volatile storage medium is provided, the non-volatile storage medium storing a plurality of instructions adapted for loading by a processor and executing any of the task processing methods described herein.

[0008] To achieve the above objectives, according to another aspect of this application, an electronic device is provided, comprising: one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement any of the task processing methods described above.

[0009] This application employs the following steps: intercepting task request information sent from an upstream server to a downstream server, wherein the upstream server converts application requirements into task request information, and the downstream server processes the application requirements corresponding to the task request information; determining an execution thread for the downstream server to perform processing based on the task request information; generating a first polling task corresponding to the execution thread and releasing the task request information when the execution thread is determined to be in an incomplete execution state, wherein the first polling task is used to monitor the execution status of the execution thread in real time; and sending the target processing result corresponding to the task request information to the upstream server when the first polling task finds that the execution thread is in a completed execution state. This achieves the goal of reducing task processing time and improving processing efficiency by converting synchronous processing to asynchronous processing, solving the problem of high thread resource requirements and low processing efficiency caused by synchronous processing occupying threads in related technologies. This ultimately improves thread utilization and enhances task processing capabilities. Attached Figure Description

[0010] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:

[0011] Figure 1 This is a flowchart of an optional task processing method provided according to an embodiment of this application;

[0012] Figure 2 This is a flowchart of an optional task processing method provided according to an embodiment of this application;

[0013] Figure 3 This is a schematic diagram of an optional task processing method provided according to an embodiment of this application;

[0014] Figure 4 This is a schematic diagram of another optional task processing method provided according to an embodiment of this application;

[0015] Figure 5 This is a schematic diagram of an optional task processing device provided according to an embodiment of this application. Detailed Implementation

[0016] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0017] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0018] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0019] For ease of description, the following explains some of the nouns or terms used in the embodiments of this application:

[0020] Microservice architecture decouples requirements by breaking down functionality into discrete services. To make it easier to understand, we can use common application scenarios as examples, such as splitting a large single application and service into several or dozens of microservices, which can be scaled up to a single component rather than the entire application stack.

[0021] It should be noted that all information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are information and data authorized by the user or fully authorized by all parties. For example, this system has an interface with relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain the relevant information after receiving consent information from the aforementioned user or organization.

[0022] Faced with ever-increasing traffic challenges, microservice architecture is often used to break down complex business processes into multiple business units, facilitating decoupling and division of labor. However, in microservice architectures with long and complex API call chains, a long processing time at one node can impact the processing time of other upstream servers calling that node, leading to prolonged call waiting times. This prevents limited server thread resources from being released in a timely manner to be reused for other tasks, resulting in an overall decrease in resource utilization. Related technologies often encounter situations where downstream heterogeneous systems or servers have excessively long response times, causing upstream application server resources to be occupied for extended periods without timely release, reducing system reusability. Furthermore, because microservices themselves have limited overall thread pool resources, the upstream server's request handling capacity weakens, and its time sensitivity decreases.

[0023] Microservice architecture combined with containerized deployment has horizontal scaling capabilities, which can alleviate the shortage of thread resources from an "open source" perspective by providing more thread pools. However, this comes at the cost of increased equipment procurement and container management.

[0024] To address the aforementioned problems, embodiments of the present invention provide a task processing method. Figure 1 This is a flowchart of a task processing method provided according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:

[0025] Step S102: Intercept task request information sent from the upstream server to the downstream server, wherein the upstream server is used to convert application requirements into task request information, and the downstream server is used to process the application requirements corresponding to the task request information.

[0026] It's understandable that the upstream server translates application requirements into the aforementioned task request information. This task request information, sent from the upstream server to the downstream server, was originally intended for synchronous processing—meaning the task request information was held until the downstream server responded. To improve processing efficiency, the task request information sent from the upstream server to the downstream server is intercepted and converted from synchronous to asynchronous processing.

[0027] Optionally, the task request information mentioned above can be of various types, such as a transaction link used in a transaction scenario, etc.

[0028] Optionally, in the task processing method provided in the embodiments of this application, task processing is performed based on a microservice architecture.

[0029] It should be noted that for microservice architecture, intercepting task request information between upstream and downstream servers for synchronous to asynchronous processing allows users of this microservice architecture to be unaware of the changes, and achieves improved processing capabilities and faster processing efficiency with minimal modifications.

[0030] Step S104: Based on the task request information mentioned above, determine the execution thread for the downstream server to perform the processing.

[0031] It's understandable that an execution thread is determined based on the task request information, and this thread is used by the downstream server for processing. It's important to note that releasing the task request information after the execution thread is created does not affect its execution.

[0032] In one optional embodiment, determining the execution thread for the downstream server to perform processing based on the task request information includes: determining the task type and task number corresponding to the task request information; and, if the task type is a request to execute a task, using the task number to generate the execution thread for the downstream server to perform processing.

[0033] It is understandable that, based on the task request information, the corresponding task type and task number can be determined. If the task type is a request to execute a task, the task number is used to generate an execution thread for downstream server processing. Through this process, after intercepting the task request information, an execution thread is generated accordingly, allowing for subsequent asynchronous processing without requiring further task request information.

[0034] In an optional embodiment, the method further includes: when the task type is a query task and no query result is found corresponding to the task request information, generating a second round of querying tasks based on the task number and releasing the task request information, wherein the second round of querying tasks is used to monitor in real time whether the query result is found; when the second round of querying tasks finds the query result, obtaining a first processing result corresponding to the task request information; and sending the first processing result to the upstream server.

[0035] It's understandable that task types also include query tasks. Query tasks are used to retrieve the processing results of tasks with corresponding task numbers. They do not require downstream server processing; they are only for querying the processing results. If no query result is found for the task request information, a second-round query task is generated based on the task number, and the task request information is released. This is considered as not needing to wait for a query result, thus reducing the occupancy of the task request information. The second-round query task monitors in real time whether a query result is found. If a query result is found in the second-round query task, the first processing result corresponding to the task request information is obtained and sent to the upstream server. Through this process, when waiting for a query result is required, the task request information can be released first, facilitating the upstream server to reuse the task request information for other purposes, thus improving overall processing efficiency.

[0036] In an optional embodiment, before obtaining the first processing result corresponding to the task request information when the second round of querying task finds the query result, the method further includes: determining the second query duration corresponding to the second round of querying task; if the second query duration is greater than a preset query duration threshold, ending the second round of querying task and sending a first timeout prompt message to the upstream server.

[0037] It is understandable that, since the first processing result is obtained from the downstream server, there may be situations where there is no response for a long time. Therefore, a second query duration is determined for the second round of queries. If the second query duration exceeds a preset query duration threshold, the second round of queries ends, and a first timeout message is sent to the upstream server. Sending the first timeout message helps to promptly identify potential problems with the downstream server and eliminate faults in a timely manner, ensuring the efficiency of task processing.

[0038] Step S106: If it is determined that the above-mentioned execution thread is in an incomplete execution state, a first polling task corresponding to the above-mentioned execution thread is generated, and the above-mentioned task request information is released. The above-mentioned first polling task is used to monitor the above-mentioned execution state of the above-mentioned execution thread in real time.

[0039] It is understandable that, when it is determined that the execution thread is in an incomplete execution state, in order to reduce the occupation of task request information, a first-round polling task corresponding to the execution thread is generated for real-time monitoring of the execution thread's execution status, and the task request information is released. Through the above processing, the task request information does not need to wait for the execution thread to complete its processing. After being released, the task request information can be used for other processing, which can be regarded as a synchronous-to-asynchronous processing method, thus improving processing efficiency.

[0040] In an optional embodiment, when there are multiple execution threads corresponding to the task request information, the step of generating a first polling task corresponding to the execution thread and releasing the task request information when it is determined that the execution thread is in an incomplete execution state includes: determining the thread number corresponding to each of the multiple execution threads; using the thread number corresponding to each of the multiple execution threads, generating the first polling task corresponding to each of the multiple execution threads, and releasing the task request information.

[0041] It's understandable that when there are multiple execution threads corresponding to a task request, this can be seen as a way to speed up processing. Multiple threads process the same task request simultaneously, using their respective thread numbers to generate a first-round polling task for each thread, and then releasing the task request. Each of these threads has a corresponding first-round polling task for real-time monitoring.

[0042] In an optional embodiment, when the first polling task finds that the execution thread is in a completed execution state, sending the target processing result corresponding to the task request information to the upstream server includes: when the first polling tasks corresponding to the plurality of execution threads all find that the execution thread is in the completed execution state, determining the thread processing result corresponding to each of the plurality of execution threads; determining the target processing result corresponding to the task request information based on the thread processing results corresponding to the plurality of execution threads; and sending the target processing result corresponding to the task request information to the upstream server.

[0043] It is understandable that, if the first round of queries for multiple execution threads all find that the execution threads are in a completed execution state, the thread processing results obtained by the multiple execution threads are determined. Based on the thread processing results corresponding to the multiple execution threads, the target processing result corresponding to the task request information is determined. The target processing result corresponding to the task request information is then sent to the upstream server.

[0044] In an optional embodiment, after generating a first polling task corresponding to the execution thread and releasing the task request information when it is determined that the execution thread is in an incomplete execution state, the method further includes: determining the calling interface corresponding to the execution thread, the calling duration threshold corresponding to the calling interface, and the first query duration corresponding to the first polling task; if the first query duration is greater than the calling duration threshold, ending the first polling task and the execution thread, and sending a second timeout notification to the upstream server.

[0045] It's understandable that when an execution thread is in an incomplete execution state, it will continuously occupy the downstream server's API call. If the downstream server fails to respond promptly for some reason, the API call will remain occupied, preventing other processing from accessing it and reducing processing efficiency. Therefore, it's necessary to determine the API call corresponding to the execution thread, the call duration threshold for that API call, and the first query duration for the first round of polling. If the first query duration exceeds the call duration threshold, it's considered that the downstream server failed to respond promptly for some reason. The first round of polling and the execution thread will then terminate, ending the occupation of the API call. A second timeout message will be sent to the upstream server to facilitate timely handling of the non-response issue.

[0046] Step S108: If the first polling task finds that the execution thread is in a completed execution state, the target processing result corresponding to the task request information is sent to the upstream server.

[0047] In the task processing method provided in this application embodiment, task request information sent from the upstream server to the downstream server is intercepted, and the task request information, which should have been directly received and executed synchronously by the downstream server, is processed asynchronously. After intercepting the task request information, the execution thread of the downstream server is determined. If the execution thread is determined to be in an incomplete execution state, a first round of polling tasks corresponding to the execution thread is generated. The first round of polling tasks is used to monitor the execution status of the execution thread in real time and release the task request information. Since the execution thread continues processing, the intervention of task request information is unnecessary, and releasing the task request information facilitates the reuse of the task request information by the upstream server. If the first round of polling tasks finds that the execution thread is in a completed execution state, the target processing result corresponding to the task request information is sent to the upstream server, improving the task processing capability of the upstream server.

[0048] It should be noted that the execution entity is a synchronous-to-asynchronous processing device located between the upstream server and the downstream server, and the aforementioned synchronous-to-asynchronous processing device is a software component.

[0049] The task processing method provided in this application, through steps S102 to S108, achieves the goal of reducing task processing time and improving processing efficiency by converting synchronous processing to asynchronous processing. This solves the problem in related technologies where synchronous processing occupies threads, leading to high thread resource requirements and low processing efficiency. Ultimately, it improves thread utilization and enhances task processing capabilities.

[0050] Based on the above embodiments and optional embodiments, the present invention proposes an optional implementation method. For ease of understanding, a microservice architecture is adopted for task processing, and a synchronous-to-asynchronous conversion device (a software component) is set up between the upstream server and the downstream server. Figure 2 This is a flowchart of an optional task processing method provided according to an embodiment of this application, such as... Figure 2 As shown, by adopting the concept of "throttling", a synchronous-to-asynchronous conversion device is set up between the upstream and downstream servers to intercept all synchronous tasks. The synchronous-to-asynchronous conversion device is then used to convert the synchronous tasks into asynchronous tasks that do not require waiting, thereby improving the utilization of server resources.

[0051] Figure 3 This is a schematic diagram of an optional task processing method provided according to an embodiment of this application, such as... Figure 3 As shown, the processing on the upstream server side involves identifying and intercepting synchronization task requests (i.e., task request information) sent from the upstream server to the downstream server. The task request information is categorized into two types: request execution tasks and query tasks. Request execution tasks require the downstream server to process them using an execution thread and return the result. Query tasks, on the other hand, are used to retrieve the processing result of a task with a corresponding task number and do not require downstream server processing; they are simply queries of the processing result.

[0052] Figure 4 This is a schematic diagram of another optional task processing method provided according to an embodiment of this application, such as... Figure 4 The diagram illustrates the processing performed on the downstream server side. Upon receiving a task request, an asynchronous execution thread is created locally to execute the task. A first-round polling task is used to monitor the execution thread in real time. Afterward, the task request information can be released, allowing the upstream server to perform other reuse processing. Releasing the task request information after thread creation does not affect the execution of the thread. Since the response or processing time of the downstream server is relatively long, this release process avoids waiting for the downstream server's response, improving processing efficiency. After the downstream server responds and completes processing, the target processing result is obtained and stored. During the next query in the first-round polling task, the target processing result is promptly sent to the upstream server.

[0053] Upon receiving a query task, a search is performed based on the task number corresponding to the task request information. If a query result corresponding to the task request information is found, the first processing result corresponding to the task request information is obtained and directly returned to the upstream server, completing the query. If no query result corresponding to the task request information is found, a second round of query tasks is generated based on the task number, and the task request information is released. This is considered as not needing to wait for a query result, thus reducing the occupation of the task request information. The second round of query tasks monitors in real time whether a query result is found. If a query result is found in the second round of query tasks, the first processing result corresponding to the task request information is obtained and sent to the upstream server.

[0054] The above optional implementation methods achieve at least one of the following effects: They solve the problem of limited thread resources in the link being occupied for a long time by a single point and unable to be released in a timely manner, thus avoiding resource waste and improving resource utilization. By adopting a synchronous-to-asynchronous processing method for task request information, the access layer or gateway layer of the microservice architecture changes from synchronous call waiting to asynchronously sending a task request information once, and monitoring the processing results through polling. For the service layer of the microservice architecture, in the actual application scenario of accepting transactions, it changes from accepting synchronous tasks to accepting asynchronous tasks, executing them asynchronously, and providing the ability to query the task processing results.

[0055] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0056] This application also provides a task processing apparatus. It should be noted that the task processing apparatus of this application can be used to execute the task processing method provided in this application. The task processing apparatus provided in this application is described below.

[0057] Figure 5 This is a schematic diagram of a task processing apparatus according to an embodiment of this application. Figure 5 As shown, the device includes: an interception module 502, a determination module 504, a generation module 506, and a sending module 508. The device will be described below.

[0058] The interception module 502 is used to intercept task request information sent by the upstream server to the downstream server. The upstream server is used to convert the application requirements into the task request information, and the downstream server is used to process the application requirements corresponding to the task request information.

[0059] The determining module 504, connected to the intercepting module 502, is used to determine the execution thread for the downstream server to perform the processing based on the task request information mentioned above.

[0060] The generation module 506, connected to the determination module 504, is used to generate a first polling task corresponding to the execution thread and release the task request information when it is determined that the execution thread is in an incomplete execution state. The first polling task is used to monitor the execution state of the execution thread in real time.

[0061] The sending module 508, connected to the generating module 506, is used to send the target processing result corresponding to the task request information to the upstream server when the first round of querying finds that the execution thread is in a completed execution state.

[0062] The task processing apparatus provided in this application embodiment includes an interception module 502 for intercepting task request information sent from an upstream server to a downstream server. The upstream server converts application requirements into task request information, and the downstream server processes the application requirements corresponding to the task request information. A determination module 504, connected to the interception module 502, determines an execution thread for the downstream server to perform processing based on the task request information. A generation module 506, connected to the determination module 504, generates a first polling task corresponding to the execution thread and releases the task request information when the execution thread is determined to be in an incomplete execution state. The first polling task monitors the execution status of the execution thread in real time. A sending module 508, connected to the generation module 506, sends the target processing result corresponding to the task request information to the upstream server when the first polling task finds that the execution thread is in a completed execution state. This achieves the goal of reducing task processing time and improving processing efficiency by converting synchronous processing to asynchronous processing. It solves the problem of high thread resource requirements and low processing efficiency caused by synchronous processing occupying threads in related technologies, thereby improving thread utilization and enhancing task processing capabilities.

[0063] It should be noted that the above modules can be implemented by software or hardware. For example, for the latter, it can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0064] It should be noted that the interception module 502, determination module 504, generation module 506, and sending module 508 correspond to steps S102 to S108 in the embodiments. The instances and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules, as part of the device, can run in a computer terminal.

[0065] It should be noted that the optional or preferred implementation methods of this embodiment can be found in the relevant descriptions in the embodiments, and will not be repeated here.

[0066] The aforementioned task processing device includes a processor and a memory. The aforementioned units are all stored in the memory as program units, and the processor executes the aforementioned program units stored in the memory to realize the corresponding functions.

[0067] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0068] This invention provides a computer-readable storage medium storing a program thereon, which, when executed by a processor, implements the above-described task processing method.

[0069] This invention provides a processor for running a program, wherein the program executes the task processing method described above.

[0070] This invention provides an electronic device, including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: intercepting task request information sent from an upstream server to a downstream server, wherein the upstream server converts application requirements into task request information, and the downstream server processes the application requirements corresponding to the task request information; determining an execution thread for the downstream server to perform processing based on the task request information; if the execution thread is determined to be in an incomplete execution state, generating a first polling task corresponding to the execution thread and releasing the task request information, wherein the first polling task is used to monitor the execution status of the execution thread in real time; and if the first polling task finds that the execution thread is in a completed execution state, sending the target processing result corresponding to the task request information to the upstream server. The device in this document can be a server, PC, PAD, mobile phone, etc.

[0071] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program with the following method steps: intercepting task request information sent from an upstream server to a downstream server, wherein the upstream server is used to convert application requirements into the task request information, and the downstream server is used to process the application requirements corresponding to the task request information; based on the task request information, determining an execution thread for the downstream server to perform processing; if it is determined that the execution thread is in an incomplete execution state, generating a first polling task corresponding to the execution thread and releasing the task request information, wherein the first polling task is used to monitor the execution status of the execution thread in real time; if the first polling task finds that the execution thread is in a completed execution state, sending the target processing result corresponding to the task request information to the upstream server.

[0072] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0073] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0074] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0075] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0076] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0077] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0078] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0079] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0080] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0081] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A task processing method, characterized in that, include: Intercepting task request information sent from an upstream server to a downstream server, wherein the upstream server is used to convert application requirements into the task request information, and the downstream server is used to process the application requirements corresponding to the task request information. Based on the task request information, an execution thread is determined for the downstream server to perform the processing; If it is determined that the execution thread is in an incomplete execution state, a first polling task corresponding to the execution thread is generated and the task request information is released. The first polling task is used to monitor the execution state of the execution thread in real time. If the first polling task finds that the execution thread is in a completed execution state, the target processing result corresponding to the task request information is sent to the upstream server; The step of determining the execution thread for the downstream server to perform processing based on the task request information includes: determining the task type and task number corresponding to the task request information; if the task type is a request to execute a task, using the task number to generate the execution thread determined for the downstream server to perform processing; if the task type is a query task and no query result corresponding to the task request information is found, generating a second polling task corresponding to the task request information based on the task number and releasing the task request information, wherein the second polling task is used to monitor in real time whether the query result is found; if the second polling task finds the query result, obtaining a first processing result corresponding to the task request information; and sending the first processing result to the upstream server.

2. The method according to claim 1, characterized in that, Before obtaining the first processing result corresponding to the task request information when the second polling task finds the query result, the method further includes: Determine the second query duration corresponding to the second polling task; If the second query duration exceeds a preset query duration threshold, the second polling task ends, and a first timeout message is sent to the upstream server.

3. The method according to claim 1, characterized in that, When there are multiple execution threads corresponding to the task request information, the step of generating a first polling task corresponding to the execution thread and releasing the task request information when it is determined that the execution thread is in an incomplete execution state includes: Determine the thread number corresponding to each of the multiple execution threads; Using the thread numbers corresponding to the plurality of execution threads, generate the first polling task corresponding to the plurality of execution threads, and release the task request information.

4. The method according to claim 3, characterized in that, When the first polling task finds that the execution thread is in a completed execution state, sending the target processing result corresponding to the task request information to the upstream server includes: If the first polling task corresponding to each of the plurality of execution threads finds that the execution thread is in the completed execution state, the thread processing result corresponding to each of the plurality of execution threads is determined. Based on the thread processing results corresponding to the multiple execution threads, the target processing result corresponding to the task request information is determined; The target processing result corresponding to the task request information is sent to the upstream server.

5. The method according to any one of claims 1 to 4, characterized in that, After determining that the execution thread is in an incomplete execution state, generating a first polling task corresponding to the execution thread, and releasing the task request information, the method further includes: Determine the calling interface corresponding to the execution thread, the calling duration threshold corresponding to the calling interface, and the first query duration corresponding to the first polling task; If the duration of the first query exceeds the call duration threshold, the first polling task and the execution thread are terminated, and a second timeout message is sent to the upstream server.

6. A task processing device, characterized in that, include: An interception module is used to intercept task request information sent from an upstream server to a downstream server. The upstream server is used to convert application requirements into the task request information, and the downstream server is used to process the application requirements corresponding to the task request information. The determining module is used to determine the execution thread for the downstream server to perform processing based on the task request information; The generation module is used to generate a first polling task corresponding to the execution thread and release the task request information when it is determined that the execution thread is in an incomplete execution state. The first polling task is used to monitor the execution state of the execution thread in real time. The sending module is used to send the target processing result corresponding to the task request information to the upstream server when the first polling task finds that the execution thread is in a completed execution state; The determining module is further configured to determine the task type and task number corresponding to the task request information; if the task type is an application to execute a task, the task number is used to generate the execution thread determined for the downstream server to perform processing; if the task type is a query task and no query result corresponding to the task request information is found, a second round-robin task corresponding to the task request information is generated based on the task number, and the task request information is released, wherein the second round-robin task is used to monitor in real time whether the query result is found; if the second round-robin task finds the query result, a first processing result corresponding to the task request information is obtained; and the first processing result is sent to the upstream server.

7. A non-volatile storage medium, characterized in that, The non-volatile storage medium stores multiple instructions, which are adapted to be loaded by a processor and executed by the task processing method according to any one of claims 1 to 5.

8. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the task processing method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method for converting HTTP synchronous requests to asynchronous processing, and server

    CN108319508A