Network request control method and device

By inserting interceptors into the message queue to handle network request response errors, the user experience issues caused by network request errors in mobile applications are resolved. This achieves orderly processing of network requests and seamless retries, thereby improving the user experience.

CN121567779APending Publication Date: 2026-02-24THE PEOPLES BANK OF CHINA DIGITAL CURRENCY INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510472715.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

In mobile applications, when a network request that needs to be executed first fails, there is no corresponding handling mechanism, which prevents subsequent network requests from continuing to be executed, resulting in a poor user experience.

Method used

A message queue-based network request control method is adopted, which handles network request response errors by inserting interceptor messages, ensuring efficient processing and enabling seamless retries.

Benefits of technology

It enables orderly processing of network requests and seamless retries for users, improving user experience and preventing user experience degradation caused by network request errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121567779A_ABST
    Figure CN121567779A_ABST
Patent Text Reader

Abstract

The invention discloses a network request control method and device, and relates to the field of computer networks. A specific embodiment of the method comprises the following steps: acquiring a front-end network request, and inserting the front-end network request into a message queue; calling a network engine to take out the message from the message queue and sending the message; when the network request response error code accords with a preset error code type, determining the corresponding network request as a target network request; determining an interceptor message corresponding to a response error code according to the network request response error code, and inserting the interceptor message in front of a message where the target network request is located; and after calling the network engine consumption interceptor message, sending a target network request to a background server. The network request can be orderly processed, the interceptor message can be set before the network request according to the response error code of the network request, the preset interceptor logic can be executed, the preprocessing of the network request or the post-processing after the error report can be realized, and the non-inductive retry of a user can be realized. The invention further provides a corresponding device, electronic equipment and a computer readable medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a network request control method, apparatus, electronic device, and computer-readable medium. Background Technology

[0002] In mobile applications, interaction with the backend is often required, using network requests to retrieve backend data and complete a specific function. When multiple network requests need to be processed, a sorting queue can be used to place them in the queue for processing. If each network request has a priority, its order in the queue can be set accordingly. However, if a network request that should be executed first fails, and there is no corresponding handling mechanism, subsequent network requests, which depend on its result, cannot continue to execute. Ultimately, the frontend returns an error to the user, resulting in a poor user experience. Summary of the Invention

[0003] In view of this, embodiments of the present invention provide a network request control method based on a message queue, which can efficiently handle network requests and flexibly handle network request errors, providing users with a seamless retry experience. Specifically, embodiments of the present invention provide a network request control method applied to a terminal, including the following steps:

[0004] Get the network requests that the front end is going to send to the backend server, and insert the network requests into the message queue as messages;

[0005] The network engine is invoked to retrieve a message from the message queue and send the network request contained in the message to the backend server;

[0006] If the received network request response error code matches the preset error code type, the corresponding network request is determined to be the target network request.

[0007] Based on the network request response error code, determine the interceptor message corresponding to the response error code, and insert the interceptor message before the message containing the target network request. The interceptor message contains interceptor logic, which is configured so that the interceptor message consumption is completed after the execution logic corresponding to the response error code is completed.

[0008] After invoking the network engine to consume the interceptor message, a target network request is sent to the backend server.

[0009] In some embodiments of the present invention, invoking the network engine to retrieve a message from the message queue and sending the network request in the message to the backend server includes:

[0010] The network engine is invoked to retrieve network requests from messages in the message queue and send the network requests from messages to the backend server in parallel.

[0011] Once the network request receives a correct response, the message containing the network request has been consumed.

[0012] Alternatively, the network engine can be invoked to retrieve the network request from the front of the message queue and send the network request from the message to the backend server.

[0013] Once a correct response to a network request is received, the message containing the network request is consumed, and the network engine is invoked to process the network request in the next message.

[0014] In some embodiments of the present invention, inserting network requests into a message queue as messages includes:

[0015] Get the priority of the network requests and insert them into the message queue according to the priority order.

[0016] In some embodiments of the present invention, the method further includes: determining an interceptor message corresponding to a network request response error code based on the network request response error code, including:

[0017] It also determines the interceptor message based on the target network request.

[0018] In some embodiments of the present invention, the execution logic includes chained execution logic composed of multiple individual execution logics linked together in execution order, and the interceptor logic is configured as follows:

[0019] Once the current single execution logic is completed, the next single execution logic will be executed in the execution order until the chain of execution logic is completed.

[0020] In some embodiments of the present invention, when the execution logic includes logic for requesting information from a backend server, the interceptor logic is further configured to: in response to the execution logic receiving a failure to obtain information, insert the execution logic into a message queue as a message, with the message corresponding to the execution logic located before the interceptor message.

[0021] In some embodiments of the present invention, an interceptor message is inserted before the message containing the target network request, including:

[0022] Insert an interceptor message at the very front of the message queue.

[0023] In some embodiments of the present invention, the interceptor logic is further configured such that: after the execution logic is completed and the message before the interceptor message is consumed, the interceptor message consumption is completed.

[0024] According to another aspect of the present invention, a network request control device is also provided, applied to a front end, including a network request acquisition module, a network engine invocation module, and a message queue management module, wherein...

[0025] The network request acquisition module is configured to acquire network requests that the front end is about to send to the backend server and insert the network requests into the message queue as messages;

[0026] The network engine invocation module is configured to invoke the network engine to retrieve a message from the message queue and send the network request in the message to the backend server;

[0027] The message queue management module is configured to determine the target network request in response to a network request response error code that matches a preset error code type; based on the network request response error code, it determines the interceptor message corresponding to the response error code and inserts the interceptor message before the message containing the target network request. The interceptor message contains interceptor logic, which is configured to complete the consumption of the interceptor message after the execution logic corresponding to the response error code is completed.

[0028] The network engine invocation module is also configured to send a target network request to the backend server after consuming interceptor messages via the network engine.

[0029] According to another aspect of the present invention, an electronic device is provided, comprising: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the embodiments of the present invention.

[0030] According to another aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method provided in the embodiments of the present invention.

[0031] One embodiment of the above invention has the following advantages or beneficial effects: In this embodiment, the network request to be sent from the front end is inserted into the message queue in the form of a message. The network engine can retrieve the message from the message queue and send the network request to the backend server for processing, which improves the orderliness of network request processing. At the same time, it can determine whether to intercept based on the network response error code of the network request and insert an interceptor message before the network request in the message queue when executing the corresponding logic. After the execution logic in the interceptor message is executed, the network request is allowed to proceed. This can easily solve the requirement that certain network requests need to be preceded by specific logic. In some business processes, it can achieve seamless retry for users and improve user experience.

[0032] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description

[0033] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:

[0034] Figure 1 This is a schematic diagram of the overall architecture of a network request control system according to some embodiments of the present invention;

[0035] Figure 2 This is a flowchart illustrating a network request control method according to some embodiments of the present invention;

[0036] Figure 3 This is a schematic diagram illustrating the process of inserting a network request into a message queue according to some embodiments of the present invention;

[0037] Figure 4a This is a schematic diagram of the process of a network engine processing network requests in parallel, according to some embodiments of the present invention.

[0038] Figure 4b This is a schematic diagram of the process by which a network engine serially processes network requests, according to some embodiments of the present invention.

[0039] Figure 5 This is a schematic diagram illustrating the parallel processing of network requests by a network engine according to some embodiments of the present invention;

[0040] Figure 6 This is a schematic diagram illustrating the serial processing of network requests by a network engine according to some embodiments of the present invention;

[0041] Figure 7 This is a schematic diagram illustrating the mapping relationship between response error code types and interceptor messages according to some embodiments of the present invention;

[0042] Figure 8 This is a schematic diagram illustrating the insertion of interceptor messages into a message queue according to some embodiments of the present invention;

[0043] Figure 9 This is a schematic diagram of the structure of interceptor messages in a message queue according to some embodiments of the present invention;

[0044] Figure 10 This is a schematic diagram of the network engine processing interceptor logic in the message queue according to some embodiments of the present invention;

[0045] Figure 11 This is a schematic diagram of the architecture of a network request control device according to some embodiments of the present invention;

[0046] Figure 12 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;

[0047] Figure 13 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation

[0048] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0049] The concepts involved in the embodiments of the present invention will be introduced below.

[0050] The message queue mentioned in this embodiment of the invention is a data structure that stores and manages messages according to the First-In-First-Out (FIFO) principle. In front-end scenarios, messages can be various types of data or instructions, such as function calls, event notifications, status updates, network requests, etc. Message queues have the following advantages: 1. Message queues decouple producers (codes that send messages) from consumers (codes that receive and process messages). Producers do not need to care when or how consumers process messages; they only need to put messages into the queue. 2. Ordering: Message queues ensure that messages are processed in the order they are enqueued, which is crucial for tasks that require sequential execution.

[0051] The synchronization barrier mechanism mentioned in this embodiment of the invention is a concurrency control mechanism, also often referred to as a barrier or synchronization point. It is used to ensure that a group of tasks all reach a common execution point before proceeding to the next task. This mechanism is commonly used in parallel processing programs to ensure data consistency, satisfy dependencies between tasks, or coordinate the activities of multiple execution units.

[0052] The interceptor mentioned in this embodiment of the invention is a widely used component in software architecture, mainly used for preprocessing and post-processing during request processing. It can perform specific operations before and after the request reaches the target processing logic, thereby achieving functions such as permission verification, logging, performance monitoring, and data validation.

[0053] The network engine mentioned in this embodiment of the invention is responsible for handling data interaction between the front end and the server. For example, the network engine can be Axios, which can be used in both browsers and Node.js environments. It supports request and response interceptors and can perform some preprocessing operations before the request is sent and after the response is received. It can automatically transform request and response data (such as automatic parsing and serialization of JSON data) and support sending multiple requests at the same time (such as the axios.all method).

[0054] like Figure 1 As shown, this embodiment of the invention provides a network request control system 100 that can run the network request control method of this embodiment of the invention, including a front-end 110 and a back-end server 120. The front-end 110 is also provided with a message queue 111 and a network engine 112.

[0055] like Figure 2 As shown, the embodiments of the present invention are based on... Figure 1 The network request control system 100 shown provides a network request control method applied to the front end 110, including:

[0056] S210: Obtain the network requests to be sent from the front end to the back end server, and insert the network requests into the message queue as messages. In this embodiment of the invention, when a user conducts business on the front end 110, the front end 110 sends network requests to the back end server 120. Each business transaction involves multiple network requests, such as requesting back end authentication, verifying login status, and sending messages. In some embodiments of the invention, the processing of some network requests requires the processing results of other network requests. For example, for transaction business processing, transaction password verification requests, login validity verification requests, and transaction message sending requests may be generated. To ensure transaction security, the transaction message sending request is only sent after the login validity verification request and transaction password verification request have been processed. Thus, different network requests have execution priorities. Executing them out of order will lead to business processing errors. This embodiment of the invention inserts network requests into the message queue to achieve network request sorting, providing a basis for orderly processing of network requests.

[0057] In some embodiments of the present invention, in order to ensure that higher-priority network requests can be retrieved earlier, network requests are inserted into the message queue in order of priority according to their respective priorities. Specifically, step S210 includes:

[0058] Get the priority of the network requests and insert them into the message queue according to the priority order.

[0059] like Figure 3 As shown, network request Req1 has a priority of 2, network request Req2 has a priority of 1, and network request Req3 has a priority of 3. Therefore, the order in which they are inserted into the message queue is Req2, Req1, and Req3, so that the network engine can retrieve Req2 first for processing.

[0060] S220: Call the network engine to retrieve a message from the message queue and send the network request in the message to the backend server.

[0061] In some embodiments of the present invention, the network engine 112 can retrieve messages from the message queue 111 in a parallel manner for processing, which can quickly process network requests. Alternatively, it can process network requests in a serial manner as needed, strictly following the order of messages in the message queue, to ensure the orderly processing of network requests.

[0062] In some embodiments of the present invention, such as Figure 4a As shown, the process by which network engine 112 processes messages in message queue 111 is as follows:

[0063] S221a: Call the network engine to retrieve network requests from messages in the message queue and send the network requests in the messages to the background server in parallel.

[0064] S222a: Once the response to the network request is correct, it is confirmed that the message containing the network request has been consumed.

[0065] In an embodiment of the present invention, the network engine 112 retrieves network requests from the message queue 111 and can send the network requests to the backend server 120 in parallel. After the backend server 120 finishes processing a network request, the corresponding message is confirmed as consumed and removed from the message queue. This effectively improves the processing efficiency of network requests.

[0066] For example, such as Figure 5 As shown in this embodiment of the invention, network requests Req1, Req2, and Req3 are inserted into message queue 111 as messages. Each business thread, acting as a producer, inserts messages containing network requests into message queue 111. The network engine 112, acting as a consumer, retrieves the network requests from messages in message queue 111 and sends network requests Req1, Req2, and Req3 to the backend server 120 in parallel. When the network request response status is correct, the message containing the corresponding network request is consumed, and message queue 111 removes the message. For example, when the response status of Req2 is correct, the message containing Req2 is removed. By sending network requests in parallel, the processing efficiency of network requests is ensured, avoiding the problems of long waiting times and poor user experience caused by serial sending.

[0067] In this embodiment of the invention, the network engine 112 retrieves network request Req1 and sends it, then retrieves Req2 and sends it, then retrieves Req3 and sends it. Before sending the current network request, it does not concern itself with the execution status of the previous network request, thus achieving parallel sending of network requests Req1, Req2, and Req3. In this embodiment of the invention, although the network engine 112 sends network requests in a sequential manner when sending network requests in parallel, the sending interval between adjacent network requests is extremely short, achieving an effect similar to sending network requests simultaneously. Similarly, when sending network requests in parallel, the interval between retrieving messages from the message queue is also extremely short, achieving an effect similar to retrieving network requests from messages in batches. In some embodiments, the network engine 112 sends network requests serially, which may reduce the efficiency of network request processing, but it can ensure the execution order of each network request. For example, the network engine 112 retrieves network request Req1, sends Req1, waits for a response to Req1, then retrieves Req2, sends Req2, waits for a response to Req2, then retrieves Req3 and sends Req3.

[0068] In some embodiments of the present invention, in order to control the execution order of network requests, network requests in the messages are retrieved from the beginning to the end of the message queue and processed sequentially, such as... Figure 4b As shown, the process by which network engine 112 processes messages in message queue 111 is as follows:

[0069] S221b: The network engine is invoked to retrieve the network request from the front of the message queue and send the network request to the backend server. In this embodiment of the invention, the message queue provides messages in a first-in, first-out manner, with the message at the front being provided first. After the current message is consumed, the front points to the next message.

[0070] S222b: After receiving a correct response to the network request, the message containing the network request is consumed, and the network engine is invoked to process the network request in the next message. The network request in the next message is retrieved.

[0071] For example, such as Figure 6 As shown, the message queue contains network requests Req1, Req2, and Req3. Network engine 112 first retrieves Req1. After network request Req1 is answered correctly, it retrieves network request Req2, and so on, processing the last network request in sequence.

[0072] S230: In response to the received network request response error code matching the preset error code type, the corresponding network request is determined to be the target network request. In this embodiment of the invention, error types can be preset. For example, for some network requests that require preprocessing but have not been preprocessed, if the backend server detects and determines that preprocessing is still required, this network request can be identified as the target network request; as another example, some network requests depend on the login status to execute, and refreshing to maintain the login status requires preprocessing, such network requests can be identified as target network requests.

[0073] S240: Based on the network request response error code, determine the interceptor message corresponding to the response error code, and insert the interceptor message before the message containing the target network request. The interceptor message contains interceptor logic configured so that the interceptor message is consumed only after the execution logic corresponding to the response error code has been completed. In this embodiment of the invention, a synchronization barrier mechanism can be used to set up the interceptor, enabling control over the execution order of specific network requests or preprocessing of specific network requests when the network engine processes network requests in parallel. Before the interceptor message is fully consumed, messages following the interceptor message are prevented from being consumed.

[0074] In this embodiment of the invention, the corresponding interceptor message can be determined based on the network request response error code, thereby determining the interception logic. Before implementation of this embodiment, the type of response error code and the interceptor logic can be associated and stored, such as... Figure 7 As shown, the interceptor logic corresponding to the response error code Err_req1 is Logi1, and its execution logic is Logi1_bar. The interceptor logic corresponding to the response error code Err_req2 is Logi2, and its execution logic is Logi2_bar. When the front end receives the response error Err_req1, it retrieves the interceptor logic Logi1 from the index, sets it in the interceptor message, and inserts the interceptor message before the target network request. For example, when the response error code indicates that the login has failed, the interceptor logic attempts to restore the login state. The specific execution logic could be verifying the device fingerprint, login token, updating the login state, etc. When the response error code indicates that the backend server public key certificate has failed, the interceptor logic attempts to update the backend server public key certificate. The specific execution logic could be requesting the backend server public key certificate and storing the backend server public key certificate.

[0075] In some embodiments of the present invention, the front-end 110 can also determine the interceptor message based on the target network request. In some embodiments of the present invention, the interceptor message can be determined based on the type of the target network request. For example, when the type of the target network request is an FTP request (File Transfer Protocol), if the network response error code indicates that authentication is missing, the corresponding interceptor logic is to attempt authentication. Specifically, the execution logic includes sending authentication information and storing the authentication status. In some embodiments of the present invention, the front-end can also determine the interceptor message based on the content of the target network request. For example, when the front-end needs to make requests to different institution back-ends, the front-end will use the public keys of different institutions to encrypt the sent messages. When the target network request is to send an asymmetric encrypted message to institution A, and the response error code indicates that the public key certificate has expired, the corresponding interceptor logic is to attempt to update institution A's public key certificate. Specifically, the execution logic can include applying for institution A's public key certificate and storing institution A's public key certificate.

[0076] In some embodiments of the present invention, the interceptor message is placed before the target network request to ensure that the interceptor logic in the interceptor message is executed first. To ensure the highest priority execution of the interceptor logic, the interceptor message can be placed at the front of the message queue. This guarantees that the request is executed with the highest priority, which is particularly important for scenarios where network requests in the message queue are processed in parallel. For example, Figure 8 As shown, message queue 111 contains network requests Req1, Req2, and Req3. Network engine 112 retrieves network requests Req1, Req2, and Req3 in parallel and sends them to the backend server 120. When the backend server's response error code for network request Req2 indicates that an interceptor message needs to be inserted, the interceptor message needs to be inserted before network request Req2. This ensures that the execution logic in the interceptor message is completed before network request Req2 is executed. The interceptor message can be inserted either before network request Req2 or at the very front of message queue 111. When the response error code indicates that the login status needs to be refreshed, the affected network requests include not only the target network request Req2 but may also affect other network requests Req1 and Req3. In this case, the corresponding interceptor message needs to be inserted at the very front of message queue 111.

[0077] In some embodiments of the present invention, the execution logic in the interceptor message can be configured as a chained execution structure as needed to ensure the execution order of multiple execution logics. In some embodiments of the present invention, the execution logic includes a chained execution logic composed of multiple individual execution logics linked together in execution order, and the interceptor logic is configured as follows:

[0078] Once the current single execution logic is completed, the next single execution logic will be executed in the execution order until the chain of execution logic is completed.

[0079] For example, such as Figure 9 As shown, the execution logic Logi_bar in the execution interceptor message has multiple single execution logics Logi_bar1, Logi_bar2, and Logi_bar3, which are linked together in the execution order and executed sequentially. After the execution is completed, the target network request Req2 is executed.

[0080] S250: After consuming the interceptor message by calling the network engine, a target network request is sent to the backend server.

[0081] In an embodiment of the invention, the network engine consumes messages from the message queue. When the message contains a network request, it sends the network request; when the message contains interceptor logic, the front-end executes the interceptor logic. After the interceptor message is consumed, the network engine continues to process subsequent target network requests. This ensures that interceptor logic is executed before target network requests.

[0082] In embodiments of the present invention, an interceptor is set before the target network request, thereby enabling the execution of corresponding preprocessing logic (execution logic) for the target network request. This ensures that when the target network request is not fulfilled due to lack of preprocessing operations or failure to meet dependent conditions, the interceptor performs preprocessing operations or resolves the dependent conditions before the target network request, and then retryes. This reduces disruption to user operations and achieves silent retry.

[0083] In some embodiments of the present invention, the execution logic in the interceptor message is executed by the front end, but it cannot be guaranteed that the execution will succeed on the first try. In order to flexibly deal with the scenario of request failure, when the execution logic involves an interaction request with the backend server, the execution logic can be set to the message queue when the execution logic fails, so that the network engine can call it to execute again. Specifically, it can be set before the interceptor message. After successful execution, the interceptor message is removed, and subsequent network requests are allowed.

[0084] Specifically, when the execution logic includes logic that requests information from the backend server, the interceptor logic is further configured to: in response to the failure to obtain information received during the execution logic, insert the execution logic into the message queue as a message, with the message corresponding to the execution logic located before the interceptor message.

[0085] For example, receiving Figure 9 Examples, such as Figure 10As shown, when Logi_bar3 needs to request information from the backend server, after receiving a failure to obtain information, Logi_bar3 is inserted as a message before the interceptor message Bar. The network engine 112 then retrieves the execution logic of Logi_bar3 from the message queue 111 to obtain the message from the backend server, ensuring that the request to obtain the message is completed.

[0086] In some embodiments of the present invention, an execution state can be set for the execution logic, such as... Figure 10 In the example, after Logi_bar3 is executed, the execution status is set to executed. After the network request of Logi_bar3 is completed from the message queue, the network engine 112 determines that the execution status of the execution logic in the interceptor message is executed, and then determines that the interceptor message consumption is complete.

[0087] In some embodiments of the present invention, the logic for removing interceptor messages can be flexibly configured. It can be configured such that after the interceptor logic is executed, the interceptor message consumption is completed, and the interceptor message is removed. At this time, the network requests before the interceptor message are processed in the order of message queue processing, since they were processed before the interceptor message.

[0088] In other embodiments of the present invention, the interceptor logic can also be configured to complete the interceptor message consumption only after the interceptor logic has been executed and the messages preceding the interceptor message have also been consumed. This is applicable when the interceptor logic triggers the generation of messages preceding the interceptor message, and it is necessary to ensure that the triggered messages are completed before allowing subsequent target network requests, thus ensuring that the interception logic in the interceptor message is fully executed.

[0089] The method in this embodiment of the invention inserts each network request into a message queue, and then retrieves the network requests from the message queue through a network engine. This enables orderly processing of network requests and, when a network request generates a preset error code, generates a corresponding high-priority interceptor message, executes the interceptor logic first, and then executes the network request that generated the error code. It allows for flexible configuration of pre-processing or post-processing flows for network requests. In the front-end implementation of this invention, based on specific scenarios, it can perform specific processing on a network request and then retry it. By setting the specific processing in the interceptor message, it enables seamless retrying for the user, improving the user experience. It also enables seamless user status refresh and seamless key update functions.

[0090] In this embodiment of the invention, for network request errors, compared to the previous solution of directly informing users of network request failures, a seamless retry process can be implemented for specific error types, avoiding disturbance to users and improving user experience.

[0091] like Figure 11 As shown, this embodiment of the invention also provides a network request control device 300, applied to the front end, including a network request acquisition module 310, a network engine invocation module 320, and a message queue management module 330, wherein...

[0092] The network request acquisition module 310 is configured to acquire network requests to be sent from the front end to the back end server and insert the network requests into the message queue as messages;

[0093] The network engine invocation module 320 is configured to invoke the network engine to retrieve a message from the message queue and send the network request in the message to the backend server;

[0094] The message queue management module 330 is configured to determine that the network request is the target network request in response to a network request response error code that matches a preset error code type; based on the network request response error code, it determines the interceptor message corresponding to the response error code and inserts the interceptor message before the message containing the target network request. The interceptor message contains interceptor logic, and the interceptor logic is configured such that the interceptor message consumption is completed after the execution logic corresponding to the response error code is completed.

[0095] The network engine call module 320 is also configured to send a target network request to the backend server after consuming interceptor messages by calling the network engine.

[0096] In some embodiments of the present invention, the network engine invocation module 320 is further configured as follows:

[0097] The network engine is invoked to retrieve network requests from messages in the message queue and send the network requests from messages to the backend server in parallel.

[0098] Once the network request receives a correct response, it confirms that the message containing the network request has been consumed.

[0099] Alternatively, the network engine can be invoked to retrieve the network request from the front of the message queue and send the network request from the message to the backend server.

[0100] Once a correct response to a network request is received, it is determined that the message containing the network request has been consumed, and the network engine is invoked to process the network request in the next message.

[0101] In some embodiments of the present invention, the network request acquisition module 310 is further configured to:

[0102] Get the priority of the network requests and insert them into the message queue according to the priority order.

[0103] In some embodiments of the present invention, the message queue management module 330 is further configured as follows:

[0104] It also determines the interceptor message based on the target network request.

[0105] In some embodiments of the present invention, the execution logic includes chained execution logic composed of multiple individual execution logics linked together in execution order, and the interceptor logic is configured as follows:

[0106] Once the current single execution logic is completed, the next single execution logic will be executed in the execution order until the chain of execution logic is completed.

[0107] In some embodiments of the present invention, when the execution logic includes logic for requesting information from a backend server, the interceptor logic is further configured to: in response to the execution logic receiving a failure to obtain information, insert the execution logic into a message queue as a message, with the message corresponding to the execution logic located before the interceptor message.

[0108] In some embodiments of the present invention, the message queue management module 330 is further configured as follows:

[0109] Insert an interceptor message at the very front of the message queue.

[0110] In some embodiments of the present invention, the interceptor logic is further configured such that: after the execution logic is completed and the message before the interceptor message is consumed, the interceptor message consumption is completed.

[0111] The device features of the embodiments of the present invention can be referred to the features of the methods and steps of the embodiments of the present invention, and the system embodiments can be combined with the features of the method embodiments to obtain new embodiments, and vice versa, and will not be repeated here.

[0112] Figure 12 An exemplary system architecture 1200 is shown that can be applied to the network request control method or network request control implementation apparatus of the present invention.

[0113] like Figure 12 As shown, system architecture 1200 may include terminal devices 1201, 1202, and 1203, a network 1204, and a server 1205. Network 1204 serves as the medium for providing communication links between terminal devices 1201, 1202, and 1203 and server 1205. Network 1204 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0114] Users can use terminal devices 1201, 1202, and 1203 to interact with server 1205 via network 1204 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 1201, 1202, and 1203, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).

[0115] Terminal devices 1201, 1202, and 1203 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0116] Server 1205 can be a server that provides various services, such as a backend management server that supports shopping websites browsed by users using terminal devices 1201, 1202, and 1203 (for example only). The backend management server can analyze and process data such as received product information query requests, and feed back the processing results (such as target push information and product information - for example only) to the terminal devices.

[0117] It should be noted that the network request control method provided in the embodiments of the present invention is generally executed by terminal devices 1201, 1202, and 1203, and correspondingly, the network request control implementation device is generally disposed in terminal devices 1201, 1202, and 1203.

[0118] It should be understood that Figure 12 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0119] The following is for reference. Figure 13 It shows a schematic diagram of the structure of a computer system 1300 suitable for implementing terminal devices or servers of the present invention. The methods or apparatus for implementing the methods in the embodiments of the present invention can be implemented on the computer system 1300. Figure 13 The terminal device or server shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.

[0120] like Figure 13As shown, the computer system 1300 includes a central processing unit (CPU) 1301, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 1302 or programs loaded from storage section 1308 into random access memory (RAM) 1303. The RAM 1303 also stores various programs and data required for the operation of the system 1300. The CPU 1301, ROM 1302, and RAM 1303 are interconnected via a bus 1304. An input / output (I / O) interface 1305 is also connected to the bus 1304.

[0121] The following components are connected to I / O interface 1305: an input section 1306 including a keyboard, mouse, etc.; an output section 1307 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1308 including a hard disk, etc.; and a communication section 1309 including a network interface card such as a LAN card, modem, etc. The communication section 1309 performs communication processing via a network such as the Internet. A drive 1310 is also connected to I / O interface 1305 as needed. Removable media 1311, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1310 as needed so that computer programs read from them can be installed into storage section 1308 as needed.

[0122] In particular, according to embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code 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 1309, and / or installed from removable medium 1311. When the computer program is executed by central processing unit (CPU) 1301, it performs the functions defined above in the system of this invention.

[0123] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—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 or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. 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 program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0124] 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 the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing 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, may 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.

[0125] The units or modules described in the embodiments of the present invention can be implemented in software or hardware. The described units or modules can also be housed in a processor; for example, a processor can be described as including a sending unit (or "module"), an acquisition unit, a determining unit, and a first processing unit. The names of these units or modules do not necessarily limit the specific unit or module itself; for example, a sending unit can also be described as "a unit that sends an image acquisition request to a connected server."

[0126] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs that, when executed by the device, cause the device to perform the methods described above.

[0127] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A network request control method, characterized in that, When applied to the front end, the method includes the following steps: Obtain the network request to be sent from the front end to the back end server, and insert the network request into the message queue as a message; The network engine is invoked to retrieve a message from the message queue and send the network request contained in the message to the backend server; If the received network request response error code matches the preset error code type, the corresponding network request is determined to be the target network request. Based on the network request response error code, an interceptor message corresponding to the response error code is determined, and the interceptor message is inserted before the message containing the target network request. The interceptor message contains interceptor logic, and the interceptor logic is configured such that the interceptor message is consumed after the execution logic corresponding to the response error code is completed. After invoking the network engine to consume the interceptor message, a target network request is sent to the backend server.

2. The method according to claim 1, characterized in that, The step of calling the network engine to retrieve a message from the message queue and send the network request in the message to the backend server includes: The network engine is invoked to retrieve network requests from messages in the message queue and send the network requests from messages to the backend server in parallel. Once the response to the network request is correct, the message containing the network request is consumed. Alternatively, the network engine can be invoked to retrieve the network request from the front of the message queue and send the network request from the message to the backend server. Once a correct response is received to the network request, the message containing the network request is consumed, and the network engine is invoked to process the network request in the next message.

3. The method according to claim 1, characterized in that, The step of inserting the network request into the message queue as a message includes: Obtain the priority of the network request, and insert the network request into the message queue according to the priority order.

4. The method according to claim 1, characterized in that, Also includes: Based on the network request response error code, determine the interceptor message corresponding to the response error code, including: The interceptor message is also determined based on the target network request.

5. The method according to claim 1, characterized in that, The execution logic includes a chained execution logic composed of multiple individual execution logics linked together in execution order, and the interceptor logic is configured as follows: Once the current single execution logic is completed, the next single execution logic will be executed in the execution order until the chain of execution logic is completed.

6. The method according to claim 1, characterized in that, When the execution logic includes logic that requests information from a backend server, the interceptor logic is further configured to: in response to the failure to obtain information during the execution of the execution logic, insert the execution logic into the message queue as a message, wherein the message corresponding to the execution logic is located before the interceptor message.

7. The method according to claim 1, characterized in that, The step of inserting the interceptor message before the message containing the target network request includes: The interceptor message is inserted at the very front of the message queue.

8. The method according to claim 1, characterized in that, The interceptor logic is further configured such that: after the execution logic is completed and the message before the interceptor message is consumed, the interceptor message consumption is completed.

9. A network request control device, characterized in that, Applied to the front end, it includes a network request retrieval module, a network engine invocation module, and a message queue management module, among which, The network request acquisition module is configured to acquire the network requests that the front end is to send to the backend server, and insert the network requests into the message queue as messages; The network engine invocation module is configured to invoke the network engine to retrieve a message from the message queue and send the network request in the message to the backend server; The message queue management module is configured to determine that the network request is the target network request in response to a network request response error code that matches a preset error code type; based on the network request response error code, determine the interceptor message corresponding to the response error code, and insert the interceptor message before the message containing the target network request; wherein the interceptor message contains interceptor logic, and the interceptor logic is configured such that the interceptor message is consumed after the execution logic corresponding to the response error code is completed; The network engine invocation module is also configured to send a target network request to the backend server after invoking the network engine to consume interceptor messages.

10. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-8.

11. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-8.