Request response method and device, electronic equipment and storage medium

By obtaining and returning the benchmark response data when the server detects a response exception, the problem that the requesting side is difficult to provide stable services when the server fails to respond, and the effect of improving the stability of the requesting side service is achieved.

CN120050335APending Publication Date: 2025-05-27BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510107238.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-23
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

In the case of failure of the server response in the prior art, it is difficult for the requesting side to provide stable services, resulting in poor user experience.

Method used

When the server detects a target request response exception, the pre-generated or real-time generated benchmark response data is obtained and returned to the requesting end to ensure that the requesting end can provide the basic functions of the service.

Benefits of technology

Through benchmark response data, the requesting side can still provide basic services when the server responds fail, improving the stability and user experience of the service.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120050335A_ABST
    Figure CN120050335A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a request response method and device, electronic equipment and a storage medium, and is applied to the technical field of data processing. The request response method is applied to a server side, and can comprise the following steps: receiving a target request sent by a request side; performing anomaly detection on the response of the target request; when the abnormality is detected, acquiring pre-generated reference response data, or generating the reference response data in real time; the reference response data is used for realizing a basic function of a service of a business type corresponding to the target request, and the basic function is used for ensuring that the service is available; wherein the reference response data comprises at least one data pair corresponding to the preset data type, and each data pair comprises a data identifier of the preset data type and a corresponding data value; and returning the reference response data to the request end. By applying the request response method and device, the electronic equipment and the storage medium provided by the embodiment of the invention, the service providing stability of the request end can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular, to a request response method, apparatus, electronic device, and storage medium. Background Art

[0002] In actual scenarios, due to reasons such as network fluctuations, excessive server pressure, or code logic mismatches, API (Application Programming Interface) requests sent by a request end to a service end often encounter situations such as unable to match policies, request timeouts, or processing exceptions, resulting in API request response failures.

[0003] In related technologies, the problem of service end response failures is usually alleviated based on a retry mechanism or a caching mechanism. However, these alleviation methods can only increase the probability of the request end obtaining response data when a successful response is received. Essentially, the request end still provides corresponding services based on the response data when a successful response is received, and the request end is still unable to provide services to users when a response fails, so the stability of the services provided by the request end is poor. Summary of the Invention

[0004] The purpose of the embodiments of the present invention is to provide a request response method, apparatus, electronic device, and storage medium to improve the stability of the services provided by the request end. The specific technical solutions are as follows:

[0005] In the first aspect implemented by the present invention, a request response method is provided, which is applied to a service end. The method includes:

[0006] Receiving a target request sent by a request end;

[0007] Performing anomaly detection on the response to the target request;

[0008] When an anomaly is detected, obtaining pre-generated reference response data, or generating reference response data in real time; the reference response data is used to implement the basic functions of the service corresponding to the business type of the target request, and the basic functions are used to ensure the availability of the service; wherein, the reference response data includes at least one data pair corresponding to a preset data type, and each data pair includes a data identifier of the preset data type and a corresponding data value;

[0009] Returning the reference response data to the request end.

[0010] Optionally, the target request includes a service identifier;

[0011] The obtaining of the pre-generated reference response data includes:

[0012] Obtain the baseline response data corresponding to the business identifier pre-configured in the configuration file or component; or,

[0013] The real-time generation of the baseline response data includes:

[0014] Call a preset function to generate the baseline response data corresponding to the business identifier.

[0015] Optionally, before obtaining the pre-generated baseline response data or generating the baseline response data in real time, the method further includes: determining whether there is response data corresponding to a historical request identical to the target request stored in the cache;

[0016] The obtaining of the pre-generated baseline response data or the real-time generation of the baseline response data includes:

[0017] If it is determined that there is no response data corresponding to a historical request identical to the target request stored in the cache, then obtain the pre-generated baseline response data or generate the baseline response data in real time.

[0018] Optionally, the method further includes:

[0019] If it is determined that there is response data corresponding to a historical request identical to the target request stored in the cache, then use the response data corresponding to the historical request as the baseline response data corresponding to the target request.

[0020] Optionally, after obtaining the pre-generated baseline response data or generating the baseline response data in real time, the method further includes:

[0021] Obtain the request real-time response data, where the request real-time response data is the result obtained by the processing end for processing the target request, and the processing end is the one in the server for processing requests;

[0022] Find the data type identifier of the data value that is a preset invalid field in the request real-time response data as the target data type identifier;

[0023] Compare the target data type identifier with the data identifiers of each preset data type in the baseline response data, and use the data value corresponding to the data identifier in the baseline response data that is the same as the target data type identifier as the data value corresponding to the target data type identifier;

[0024] Combine the data value corresponding to the target data type identifier and the data values corresponding to other data type identifiers in the request real-time response data as the baseline response data corresponding to the target request, where the other data type identifiers represent data type identifiers other than the target data type identifier.

[0025] Optionally, after obtaining pre-generated benchmark response data or generating benchmark response data in real time, the method further includes:

[0026] Obtaining data obtained by other preset methods, where the other preset methods include the preset methods in the multiple preset methods except for the preset method with an exception. A processing end in the server for processing requests processes the target request through multiple preset methods together, and the preset method with an exception means that an exception is detected when processing the target request using the preset method;

[0027] Modifying the benchmark response data based on the data obtained by the other preset methods to obtain modified benchmark response data.

[0028] Optionally, the modifying the benchmark response data based on the data obtained by the other preset methods to obtain modified benchmark response data includes:

[0029] For each data identifier of the preset data type in the benchmark response data, checking whether there is a data type in the data obtained by the other preset methods that represents the same meaning as the data identifier;

[0030] If so, modifying the data value corresponding to the data identifier in the benchmark response data to the data value corresponding to the data type that represents the same meaning as the data identifier in the data obtained by the other preset methods.

[0031] Optionally, the performing anomaly detection on the response to the target request includes:

[0032] Executing a preset anomaly check logic and capturing the execution result;

[0033] Based on the execution result, looking up the correspondence between the preset execution result and the anomaly type to determine the anomaly type to which the anomaly belongs.

[0034] In a second aspect of the implementation of the present invention, a request response device is provided, which is applied to a server. The device includes:

[0035] A receiving module, configured to receive a target request sent by a request end;

[0036] An anomaly detection module, configured to perform anomaly detection on the response to the target request;

[0037] A reference response data acquisition module, configured to obtain pre-generated reference response data or generate reference response data in real time when an anomaly is detected; the reference response data is used to implement the basic functions of the service corresponding to the target request, and the basic functions are used to ensure the availability of the service; wherein, the reference response data includes data pairs corresponding to at least one preset data type, and each data pair includes a data identifier of the preset data type and a corresponding data value;

[0038] A return module, configured to return the reference response data to the request side.

[0039] In a third aspect of the embodiments of the present invention, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;

[0040] The memory is used to store a computer program;

[0041] When the processor is configured to execute the program stored on the memory, it implements the request response method described in the first aspect above.

[0042] In a fourth aspect of the embodiments of the present invention, a computer-readable storage medium is provided, and a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, it implements the request response method described in the first aspect above.

[0043] In still another aspect of the embodiments of the present invention, a computer program product including instructions is provided, and when it runs on a computer, it causes the computer to execute the request response method described in the first aspect above.

[0044] In the embodiments of the present invention, when the server detects an anomaly in the target request response, it can still obtain the reference response data and return the reference response data to the request side. Even if the server has a response anomaly, the request side can still receive the reference response data for implementing the basic functions of the service corresponding to the target request. In this way, the request side can provide the basic services of related services to the user based on the reference response data, thereby improving the stability of the services provided by the request side. Description of the Drawings

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art.

[0046] Figure 1 It is a flowchart of a request response method provided by an embodiment of the present invention;

[0047] Figure 2Schematic diagram of the display interface in the related technology provided by the embodiments of the present invention when the response fails;

[0048] Figure 3 Schematic diagram of the commodity information interface provided by the embodiments of the present invention;

[0049] Figure 4 Another flowchart of the request response method provided by the embodiments of the present invention;

[0050] Figure 5 Another flowchart of the request response method provided by the embodiments of the present invention;

[0051] Figure 6 Comparison diagram of the business interfaces before and after modifying the reference response data using partial successful response data provided by the embodiments of the present invention;

[0052] Figure 7 Another flowchart of the request response method provided by the embodiments of the present invention;

[0053] Figure 8 Schematic diagram of the structure of the request response device provided by the embodiments of the present invention;

[0054] Figure 9 Schematic diagram of the structure of the electronic device provided by the embodiments of the present invention. Detailed implementation manners

[0055] Next, the technical solutions in the embodiments of the present invention will be described with reference to the accompanying drawings in the embodiments of the present invention.

[0056] In Internet applications, Java API (Java Application Programming Interface, predefined functions) is widely used in front-end and back-end interactions and inter-service communications. However, in actual scenarios, due to reasons such as network fluctuations, excessive server pressure, or code logic mismatches, API requests sent by the request side to the service side often fail to respond. For example, response failures caused by situations such as inability to match policies, request timeouts, or processing exceptions, which in turn make it difficult for the request side to provide corresponding services.

[0057] In the related technology, the above problems are usually alleviated based on a retry mechanism or a caching mechanism.

[0058] The retry mechanism refers to setting the number of retries and the time interval, so that when the request response fails, the request side sends the same request to the service side again to try to obtain a successful response.

[0059] The caching mechanism means that the requesting end stores the successful response results of different requests. Thus, when a request is made, it first checks whether there is a stored successful response result for the same request. If so, it directly uses this successful response result; if not, it sends a request to the server.

[0060] It can be seen that for the retry mechanism, it only utilizes multiple opportunities to increase the probability of obtaining a successful response result from the server. In essence, it still relies on the response result when the server has a successful response to provide corresponding services; while the caching mechanism obviously also provides services using the response results obtained during previous successful responses. Therefore, when facing a server response failure, the existing mitigation methods still cannot provide services to users at the requesting end, resulting in poor stability of service provision at the requesting end to the user side.

[0061] In view of the above problems, an embodiment of the present invention provides a request response method applied to a server, as Figure 1 shown, which may include:

[0062] S101, receiving a target request sent by a requesting end;

[0063] S102, performing anomaly detection on the response to the target request;

[0064] S103, when an anomaly is detected, obtaining pre-generated reference response data, or generating reference response data in real time; the reference response data is used to implement the basic functions of the service corresponding to the service type of the target request, and the basic functions are used to ensure the availability of the service; wherein, the reference response data includes at least one data pair corresponding to a preset data type, and each data pair includes a data identifier of the preset data type and the corresponding data value;

[0065] S104, returning the reference response data to the requesting end.

[0066] For the request response method provided by the embodiment of the present invention, when the server detects an anomaly in the target request response, it can still obtain the reference response data and return the reference response data to the requesting end. So that even if the server has a response anomaly, the requesting end can still receive the reference response data for implementing the basic functions of the service corresponding to the service type of the target request. In this way, the requesting end can provide basic services for relevant services to users based on this reference response data, thereby improving the stability of service provision at the requesting end.

[0067] In S101, the target request may include a Java API request. The target request is used to obtain relevant data for implementing a service. For example, when the target request is a product information query request, the relevant data for implementing the service may include the product name, product ID (Identity document), product price, product description, etc. Thus, the requesting end can generate a business interface based on this data and provide business services to users. Different services may correspond to different business interfaces.

[0068] In an implementable manner, different services can be defined using a service identifier, that is, different service identifiers represent different service types.

[0069] The target request includes a service identifier. After receiving the target request, the server can determine the service type requested by the current requesting end by identifying the service identifier, that is, determine the service requested by the current requesting end.

[0070] In an implementable manner, the service type may include a product information query service, a user information query service, an order information query service, etc.

[0071] In S102, during the life cycle of the target request, the Filter or Interceptor of the Spring framework (an open-source Java application framework) can be used to detect whether an exception occurs in the response of the target request. That is, S102 may include using preset exception checking logic in the interceptor or filter to perform exception detection on the response of the target request.

[0072] Exception detection can be performed using preset exception checking logic at three stages: before the target request starts to respond, during the processing of the target request, and before returning to the requesting end after the target request response is completed.

[0073] In an implementable manner, a class implementing the Filter or HandlerInterceptor interface can be created, and the doFilter() method (preprocessing method) or preHandle() method (preprocessing method) can be correspondingly implemented, and exception capture logic can be added to this preprocessing method, so as to execute exception checking logic in the filter or interceptor and capture the exceptions that occur. For example, exceptions such as timeouts, network exceptions, and internal server errors.

[0074] The preset exception checking logic for the interceptor to detect exceptions before the target request starts to respond may include the following code example.

[0075] public class ExceptionInterceptor implements HandlerInterceptor {

[0076] @Override

[0077] public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

[0078] try {

[0079] / / Exception detection before executing business logic

[0080] return true;

[0081] } catch (Exception e) {

[0082] / / Handling when an exception is detected

[0083] response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

[0084] response.getWriter().write(generateBaseResponseData(e));

[0085] return false;

[0086] }

[0087] }

[0088] }

[0089] The preHandle() method has three parameters: HttpServletRequest request (the object containing the request information, denoted as request), HttpServletResponse response (the object used to send responses to the client, denoted as response), and Object handler (the processing method to be called).

[0090] The above code example executes the try...catch... (try...catch...) logic through the preHandle() method before the target request starts to be responded, so as to catch possible exceptions before the target method starts to execute, and record the caught exception as Exception e (exception e).

[0091] When an exception is caught, the response.setStatus() method can be used to set the status for the response to be sent to the client. In the above code example, the status of the response can be set to "HttpServletResponse.SC_INTERNAL_SERVER_ERROR", that is, the HTTP (HyperText Transfer Protocol) status code with a value of 500, to indicate that the server has encountered an unexpected situation and cannot complete the request. And use the response.getWriter().write() method to write the text content referred to by "generateBaseResponseData(e)" into the response to be sent to the client. Among them, generateBaseResponseData(e) means the baseline response data generated according to exception e. The detailed content will be described later and will not be elaborated here.

[0092] In the embodiment of the present invention, when using an interceptor, in cooperation with the preHandle() method, the postHandle() method (post-processing method) and the afterCompletion() method (post-completion method) can also be used. In this way, exceptions occurring in each stage during the processing of the target request and after the target request response is completed and before returning to the request side can be caught.

[0093] The embodiment of the present invention can perform real-time exception detection by using an interceptor or a filter, so as to timely detect and intercept abnormal requests occurring during the process of responding to the target request, thereby improving the timeliness of exception handling and subsequent baseline response data generation.

[0094] In one implementable manner, a preset exception check logic is executed and the execution result is captured; based on the execution result, the corresponding relationship between the preset execution result and the exception type is searched to determine the exception type to which the exception belongs.

[0095] The preset exception check logic can be the try...catch... (try...catch...) logic. Exceptions of different exception types can capture different execution results. For example, the execution result can be a status code. The corresponding relationship between the preset execution result and the exception type can be stored in advance. When the execution result is captured, based on this execution result, the exception type to which the caught exception belongs can be determined.

[0096] In S103, the reference response data is used to implement the basic functions of the service corresponding to the target request, and the basic functions are used to ensure the availability of the service.

[0097] In one implementable manner, when the service type is an information query service, the reference response data for ensuring the availability of the service may include the basic data used to form the service interface corresponding to the service type. The basic data can be understood as the most basic data required for the service to be realized by the content displayed on the service interface. For example, for a commodity information query service, at least the data related to the commodity is required to realize the commodity information query service. At this time, the basic data may include the commodity name, commodity ID, commodity price, and commodity description.

[0098] S103 can also be understood as the process of how the server processes the detected exceptions.

[0099] In the related art, when the server detects an exception, it is considered that the server fails to respond to the target request. At this time, the server will feedback the response failure to the request side, and it is difficult for the request side to provide the business service to the user based on the feedback from the server, such as the HTTP status code (HyperText Transfer Protocol status code) corresponding to the exception, thereby affecting the stability of the request side to provide the business service. As Figure 2 shown, in the related art, when the server responds with a failure, the request side can display a corresponding error interface according to the HTTP status code returned by the server. For example, it can display "404 error...". It can be seen that this error interface cannot provide the business service to the user.

[0100] In the embodiments of the present invention, the reference response data can be used as the response result to be returned to the request side, so that after the server detects an exception, instead of feedbacking the response failure to the request side, the reference response data is sent to the request side as the response to the target request.

[0101] Since the reference response data can ensure the availability of the service, even if an exception is detected, the data that can ensure the availability of the service can be feedbacked to the request side, so that even if an exception occurs, the request from the request side can be responded to. Therefore, when the server responds with a failure, based on the reference response data, the application success rate can be improved.

[0102] Moreover, in the embodiments of the present invention, the server obtains and returns the reference response data to the request side, which can also avoid the problems in the related art that the retry mechanism and the cache mechanism have limited effects in the face of complex exception situations, and further lead to resource waste and an increase in system complexity.

[0103] Taking the commodity information query service as an example, as Figure 3As shown, the requesting end can generate a product information interface using the reference response data. This interface can provide basic business services for users and display the product information queried by users, such as showing "Product A, product ID XXXXXXXXXX, price XX yuan, product description XXXXXXXXXXXXXXXXXXX." In this way, the response success rate of the server end in abnormal situations can be improved, the display failure problem of the business interface of the requesting end caused by response failure can be reduced, the robustness can be enhanced, and the user experience can be improved.

[0104] The reference response data includes at least one data pair corresponding to a preset data type; each data pair includes a data identifier of the preset data type and the corresponding data value. Usually, the reference response data can include multiple data pairs, and the data values corresponding to the respective data identifiers can be preset default values.

[0105] The reference response data can be generated in advance or in real time.

[0106] In one implementation, the reference response data corresponding to the service identifier is generated in real time by calling a preset function.

[0107] Among them, the preset function can be determined according to the service type corresponding to the service identifier. For example, when the service type is an information query service, the calling function can specifically be a data acquisition function, and specifically, the data acquisition function can be selected according to actual requirements. For example, when the service type is specifically a product information query service, a user information query service, an order information query service, etc., the reference response data corresponding to the service identifier can be generated by data acquisition functions with different parameter values. Under different service types, the parameter values can represent the data types of the data to be acquired, etc.

[0108] In another implementation, the reference response data can be pre-configured. For example, the reference response data corresponding to each service type is pre-configured in a configuration file or a related component, such as a Service component (service component). For example, the reference response data corresponding to the service identifier of each service is configured. Furthermore, S103 can use the configuration file or the method of injecting components, through a preset logic, such as a configuration class for obtaining the reference response data, to obtain the reference response data corresponding to the service type corresponding to the target request. In this way, using the configuration file or the related component means the reference response data, and the reference response data can be decoupled from the system logic, which is convenient for the modification and extension of the reference response data.

[0109] Understandably, the business interfaces of different business types can be different, and thus the benchmark response data for realizing the basic functions of services of different business types can be different. For example, the business types can include commodity information query service, user information query service, order information query service, etc. The benchmark response data for realizing the services of these business types can be the benchmark response data that constitutes the business interfaces of different business types, and the benchmark response data of the business interfaces of these different business types can also be different.

[0110] In an embodiment of the present invention, when the business type is a commodity information query service, the benchmark response data corresponding to the commodity information query service may include multiple data pairs with data identifiers such as commodity ID, commodity name, commodity price, commodity description, etc.

[0111] In an implementable manner, the benchmark response data corresponding to the commodity information query service pre-configured in the configuration file may have the following default form.

[0112] {

[0113] "productId": "unknown",

[0114] "productName": "unknown",

[0115] "price": "100.00",

[0116] "description": "default description"

[0117] }

[0118] Among them, the data value corresponding to the data identifier productId (commodity ID) is unknown (undefined); the data value corresponding to the data identifier productName (commodity name) is unknown (undefined); the data value corresponding to the data identifier price (commodity price) is 100.00; the data value corresponding to the data identifier description (commodity description) is defaultdescription (default statement).

[0119] In an embodiment of the present invention, the data values corresponding to the above data identifiers can be set according to actual situations. For example, the data value corresponding to the data identifier productId can be set to 001; the data value corresponding to the data identifier productName can be set to bread; the data value corresponding to the data identifier price can be set to 5.00; the data value corresponding to the data identifier description can be set to milk bread with jam filling. The specific setting method is not limited in the embodiment of the present invention.

[0120] When the service type is the user information query service, the reference response data corresponding to the user information query service may include multiple data pairs with data identifiers such as user ID, user basic information, such as contact phone number, contact email, contact address, etc.

[0121] In an implementable manner, the reference response data corresponding to the user information query service pre-configured in the configuration file may have the following default form.

[0122] {

[0123] "userId": "unknown",

[0124] "userName": "defaultUser",

[0125] "email": "default@example.com",

[0126] "address": "default address"

[0127] }

[0128] Among them, the data value corresponding to the data identifier userId (user ID) is unknown; the data value corresponding to the data identifier userName (user name) is defaultUser (default user name); the data value corresponding to the data identifier email (contact email) is default@example.com (default email); the data value corresponding to the data identifier address (contact address) is default address (default address).

[0129] In the embodiments of the present invention, the data values corresponding to the above data identifiers can be set according to the actual situation. For example, the data value corresponding to the data identifier userId can be set to 00001; the data value corresponding to the data identifier userName can be set to AAA; the data value corresponding to the data identifier email can be set to AAA@example.com; the data value corresponding to the data identifier address can be set to XXX Road, YY Community. The specific setting method is not limited in the embodiments of the present invention.

[0130] When the service type is the order information query service, the reference response data corresponding to the order information query service may include multiple data pairs with data identifiers such as order ID, order status information, etc.

[0131] In an implementable manner, the reference response data corresponding to the order information query service pre-configured in the configuration file may have the following default form.

[0132] {

[0133] "orderId": "unknown",

[0134] "orderStatus": "processing",

[0135] "estimatedDelivery": "not available"

[0136] }

[0137] Among them, the data value corresponding to the data identifier orderId (order ID) is "unknown"; the data value corresponding to the data identifier orderStatus (order status) is "processing" (in progress); the data value corresponding to the data identifier estimatedDelivery (estimated delivery time) is "not available" (unestimable).

[0138] In the embodiments of the present invention, the data values corresponding to the above data identifiers can be set according to the actual situation. For example, the data value corresponding to the data identifier orderId can be set to 10000; the data value corresponding to the data identifier orderStatus is set to "processing"; the data value corresponding to the data identifier estimatedDelivery is set to dd / mm / yyyy. The specific setting method is not limited in the embodiments of the present invention.

[0139] In an optional embodiment, before obtaining the pre-generated reference response data in S103 or generating the reference response data in real time, it further includes: determining whether there is response data corresponding to a historical request identical to the target request stored in the cache;

[0140] If it is determined that there is no response data corresponding to a historical request identical to the target request stored in the cache, then obtain the pre-generated reference response data, or generate the reference response data in real time;

[0141] If it is determined that there is response data corresponding to a historical request identical to the target request stored in the cache, then use the response data corresponding to the historical request as the reference response data corresponding to the target request.

[0142] The server can receive the same target request multiple times. For example, target requests sent by different requestors for obtaining the price of a certain commodity. Therefore, before the target request received this time, the server may have successfully responded to a historical request that is the same as the target request, and obtained the response data of the historical request that is the same as the target request. The response data of this historical request can also be understood as successful response data.

[0143] In this way, before executing S103, it can be first determined whether the received target request has ever been successfully responded to, that is, it is determined whether there is response data corresponding to a historical request that is the same as the target request. If so, that is, the server stores the response data corresponding to the historical request that is the same as the target request, and at this time, directly obtain the response data corresponding to the historical request; if not, that is, the server does not store the response data corresponding to the historical request that is the same as the target request, and at this time, S103 can be executed again to obtain the reference response data.

[0144] In an optional embodiment, after obtaining the pre-generated reference response data in S103, or after generating the reference response data in real time, as Figure 4 shown, it may further include:

[0145] S401, obtaining request real-time response data, where the request real-time response data is the result obtained by the processing end for processing the target request, and the processing end is used for processing requests in the server;

[0146] S402, finding the data type identifier with a data value of a preset invalid field in the request real-time response data as the target data type identifier;

[0147] S403, comparing the target data type identifier with the data identifiers of each preset data type in the reference response data, and using the data value corresponding to the data identifier that is the same as the target data type identifier in the reference response data as the data value corresponding to the target data type identifier;

[0148] S404, combining the data value corresponding to the target data type identifier and the data values corresponding to other data type identifiers in the request real-time response data as the reference response data corresponding to the target request, where the other data type identifiers represent data type identifiers other than the target data type identifier.

[0149] In this case, the modified reference response data obtained in S404 can be returned to the requestor, or it can also be understood that S104 includes S405: returning the modified reference response data obtained in S404 to the requestor.

[0150] In some cases, although an exception occurs, the processing end in the server for processing requests has processed the target request and also obtained a result, which is the real-time response data of the request. The real-time response data of the request may include multiple data pairs.

[0151] Although the real-time response data of the request can be obtained, the data values in the data pairs included in the real-time response data of the request may be uninitialized or empty, that is, there may be blank or error data. At this time, the above-mentioned reference response data can be used to modify the empty data values in the real-time response data of the request to make them reasonable. Specifically, the modification is implemented through the above S402 to S404.

[0152] For example, when querying the commodity price in the commodity information query service, if the data value corresponding to the data identifier A representing the commodity price of the commodity is null (invalid), at this time, the reference response data corresponding to the service identifier of the commodity information query service can be used, and the data value corresponding to the data identifier A in the reference response data (which can be denoted as the default value here) is used to modify the null to the default value.

[0153] In an optional embodiment, after obtaining the pre-generated reference response data in S103 or generating the reference response data in real time, as Figure 5 shown, it may further include:

[0154] S501, obtaining the data obtained by other preset methods, where the other preset methods include the preset methods other than the preset method with an exception among the multiple preset methods, and the processing end in the server for processing requests processes the target request through the multiple preset methods together, and the preset method with an exception means that an exception is detected when processing the target request using the preset method;

[0155] S502, modifying the reference response data based on the data obtained by other preset methods to obtain the modified reference response data.

[0156] In this case, the modified reference response data obtained in S502 can be returned to the request end, or it can be understood that S104 includes S503: returning the modified reference response data obtained in S502 to the request end.

[0157] S502 may include:

[0158] For each data identifier of the preset data type in the reference response data, check whether there is a data type with the same meaning as the data identifier in the data obtained by other preset methods; if so, modify the data value corresponding to the data identifier in the reference response data to the data value corresponding to the data type with the same meaning as the data identifier in the data obtained by other preset methods.

[0159] The processing end in the server for processing requests processes the target request through multiple preset methods together.

[0160] For example, in practical applications, after the server receives the target request, it can implement the response to the target request by executing multiple preset methods corresponding to the service identifier included in the target request. For example, a certain information acquisition method expects to acquire three types of data, and these three types of data are stored in three databases (database A, database B, and database C) respectively. At this time, the processing end can include three preset methods for acquiring data from database A, database B, and database C respectively, and can implement the response to the target request by executing the corresponding preset methods.

[0161] Therefore, it can be understood that it is not necessarily the case that the server will detect an abnormal response to the target request only when all the methods for implementing the target request have exceptions. Continuing with the above example, it is possible that the data acquisition from database A and database B is normal, and only an exception occurs when acquiring data from database C. At this time, although the exception only occurs in the data acquisition from database C, it will also cause an abnormal response to the target request.

[0162] However, for the data obtained from the part of the target request that has been processed but no exception has been detected, such as the data obtained from database A and database B mentioned above, it can be considered as valid data, and it is reasonable to send this data to the request end. This data can also be called partial successful response data, that is, the response data corresponding to the part of the target request that has been successfully processed when an exception is detected, that is, the data obtained by the above other preset methods (the preset methods other than the preset method with an exception among the multiple preset methods for jointly processing requests).

[0163] In an optional embodiment, to make the data sent to the request end in subsequent S104 more reasonable, the benchmark response data obtained in the above embodiment can be modified. That is, before returning the benchmark response data to the request end, when an exception is detected, it is judged whether there is partial successful response data; if there is, the benchmark response data is modified by using the specific method of the above S502 based on the data obtained by other preset methods to obtain the modified benchmark response data. Then, in subsequent S104, the modified benchmark response data is returned to the request end.

[0164] For example, in the commodity information query service, no exception occurs when acquiring the commodity ID, commodity name, and commodity price, and an exception only occurs when acquiring the commodity description. Then, the acquired commodity ID, commodity name, and commodity price can be called partial successful response data. If the benchmark response data is not modified by using the partial response data, the service interface generated by the request end according to the received benchmark response data can be as Figure 6In the left example, the commodity price can be a preset default price, such as 100 yuan; after modifying the baseline response data using some successful response data, the business interface can be as Figure 6 In the right example, the commodity price can be the actually obtained price, such as 80 yuan. Thus, it can be seen that modifying the baseline response data using some successful response data makes the modified baseline response data more reasonable, and further enables the request side to generate a more reasonable business interface using the modified baseline response data, improving the user experience.

[0165] In the embodiment of the present invention, during the response process for the target request, the return results of each preset method for implementing the target request can be recorded. Thus, when an exception is detected, it can be determined whether there is some successful response data by judging whether there is a recorded return result and / or whether the return result includes valid information.

[0166] In an optional embodiment, each recorded return result can be used as normal response data and returned to the request side in subsequent S104 when no exception is detected all the time.

[0167] In an implementable manner, when an exception is detected, the exception type of the exception can be not distinguished, and the baseline response data of the service type corresponding to the target request can be directly obtained. For example, the baseline response data corresponding to the service identifier representing the service type can be obtained.

[0168] In another implementable manner, when an exception is detected, the exception type of the exception can also be distinguished to obtain the baseline response data. That is, before obtaining the baseline response data corresponding to the service identifier, the method can further include: obtaining the exception type of the detected exception; and obtaining the baseline response data corresponding to the service identifier and the exception type.

[0169] An exception is the reason that causes the server side to be unable to successfully respond to the target request. In the embodiment of the present invention, the exception type can include data acquisition exception, timeout exception, internal server exception, etc.

[0170] Among them, a data acquisition exception is an exception where data cannot be obtained due to reasons such as database connection failure and missing key fields. A timeout exception is an exception caused by the request processing exceeding a preset time threshold. An internal server exception is an exception where the execution logic is normal but valid data cannot be obtained, such as NullPointerException (null pointer exception), internal call failure, etc.

[0171] In an implementable manner, when the exception type is a data acquisition exception, obtain the reference response data corresponding to the service identifier. In this way, even if a data acquisition exception occurs on the server side and the expected data cannot be obtained, the reference response data can still be obtained and used as the data to be returned to the requesting end in the subsequent S104.

[0172] For example, during certain promotional activities, the prices of goods will change. When querying the prices of goods in the goods information query service, if a data acquisition exception occurs, although the promotional prices of the goods cannot be obtained at this time, the reference response data can still be obtained. The default price of the goods recorded in the reference response data is returned to the requesting end, enabling the requesting end to use the default price of the goods to provide relevant services for the goods information query service.

[0173] In an implementable manner, when the exception type is a timeout exception, determine whether the normal response data corresponding to the target request is stored in the cache. The normal response data is the response data corresponding to the historical request that is the same as the above-mentioned target request.

[0174] If it is determined that the response data corresponding to the historical request that is the same as the target request is stored in the cache, then use the response data corresponding to the historical request as the reference response data corresponding to the target request; if it is determined that the response data corresponding to the historical request that is the same as the target request is not stored in the cache, then execute step S103 to obtain the pre-generated reference response data, or generate the reference response data in real time.

[0175] When a timeout exception occurs, it can first be determined whether the received target request has been successfully responded to. If so, that is, the normal response data corresponding to the target request is stored in the server, and the normal response data can be directly obtained at this time; if not, that is, the normal response data corresponding to the target request is not stored in the server, then the reference response data corresponding to the service identifier can be obtained, that is, execute S103 to obtain the reference response data.

[0176] In an implementable manner, when the exception type is an internal server exception, although the real-time request response data can be obtained, the data values in the data pairs included in the real-time request response data may be uninitialized or empty, that is, there may be blank or error data, etc. The method shown in Figure 4 can be used to modify the real-time request response data by using the above-mentioned reference response data.

[0177] For example, when querying the price of a product in the product information query service, if the data value corresponding to the data identifier A representing the product price of the product is null (invalid), at this time, the reference response data corresponding to the service identifier of the product information query service can be obtained, and the null value can be modified to the default value (which can be denoted here as the default value) corresponding to the data identifier A in the reference response data.

[0178] In the embodiments of the present invention, for services of different service types and different exceptions that occur under different service types, the reference response data can be dynamically generated according to preset rules, rather than simply making a unified static fallback response when an exception occurs. For example, uniformly prompting "An error occurred". In this way, it can better adapt to the actual scenario and provide a more reasonable response.

[0179] The embodiments of the present invention can obtain the exception type of the exception, and it is also more convenient for technicians to perform exception analysis and system optimization according to the exception type.

[0180] In S104, after the server obtains the reference response data, it can write the reference response data into the response object for the target request and return it to the request side, so as to ensure that the server can return a reasonable response, avoid problems of display at the request side and two-sided interaction, and thus improve the robustness and user experience of the service provided by the request side.

[0181] The above describes the process of performing exception detection on the response to the target request and handling it when an exception is detected. For the case where no exception is detected, in an optional embodiment, after performing exception detection in S102, when no exception is detected, it may further include: when no exception is detected, returning normal response data to the request side, and the normal response data is the result obtained by the processing side for processing the target request for processing the request. When no exception is detected, it can be considered that all the normal response data obtained by the server is reliable data. At this time, there is no need to obtain the reference response data anymore, and the normal response data can be returned to the request side.

[0182] The request response method provided by the embodiment of the present invention detects abnormal situations in requests by intercepting and judging abnormalities in the target request response, obtains benchmark response data according to preset rules when an abnormality is detected, and returns the benchmark response data to the request side. Through a flexible benchmark response strategy, the server can provide more adaptable response data to the request side in various abnormal situations, realizing that even in the case of response failure, it is possible to obtain and send to the request side the basic data of the service interface of the service that can constitute a business identity indication, improving the success rate of the server response, especially the interface response success rate of the server for different Java API requests received, ensuring that the request side can still provide basic functions based on this data in the case of server abnormalities, guaranteeing basic services, and improving the robustness of the services provided by the request side.

[0183] Moreover, different from the conventional degradation schemes in the related art (for example, as long as an abnormality occurs, an error prompt interface is returned), the embodiment of the present invention not only provides static benchmark response data in abnormal situations, but also can dynamically generate more flexible and adaptable response data according to the actual situation. The response data returned to the request side can better meet the actual needs, avoiding more problems that may be caused by a simple degradation response.

[0184] In an implementable manner, the generation rules of the benchmark response data can be adjusted and optimized in real time based on machine learning or intelligent algorithms, so that the generation of the benchmark response data can dynamically adapt to more application scenarios, and improve the accuracy and effectiveness of the response. At the same time, for the impact degree of the abnormality, the abnormality can be classified into levels, and then when an abnormality is detected, a hierarchical response strategy can be provided by combining multiple abnormality levels to ensure the optimal processing scheme under different abnormality levels.

[0185] Refer to Figure 7 , the embodiment of the present invention provides a request response method, which is applied to a request response system. The request response system may include a request side and a server side; among them, the request side may include mobile devices, such as smart phones, tablets, etc., and may also include a PC side (personal computer, private computer), etc. The server side may include, but is not limited to, server sides set up by various Internet companies, enterprises providing API services, e-commerce platforms, fintech companies, etc. The method may include:

[0186] S701, the request side sends a target request to the server side.

[0187] S701 may be executed by the request side 71. The request side 71 may, according to the current business requirements, for example, the request side 71 may determine the business identifier of the triggered business in response to the triggering operation of the business in the interface displayed by the request side 71, and send a business request including the business identifier to the server side 72.

[0188] S702, the server receives a target request and uses an interceptor to detect whether the response of the target request is abnormal.

[0189] An exception detection module may be set in the server 72. In this exception detection module, a class implementing the interceptor interface may be created, and exception capture logic may be added to the preset method of the interceptor. Thus, after receiving the target request, the target request is forwarded to the interceptor, and the exception check logic is executed in the interceptor to detect whether an exception occurs.

[0190] S702 may correspond to S101 - S102 in the foregoing embodiments.

[0191] S703, when the server detects an abnormality, it obtains reference response data.

[0192] A reference response data acquisition module may be set in the server 72. When an abnormality is detected, the reference response data corresponding to the service identifier is obtained; and more specifically, the reference response data corresponding to the service identifier and the exception type is obtained.

[0193] S703 may correspond to the foregoing S103.

[0194] S704, the server makes a response return.

[0195] The server 72 returns the obtained reference response data to the request side 71. Thus, after the request side 71 receives the reference response data, it can use the reference response data to generate a corresponding service interface and provide basic service services.

[0196] S704 may correspond to the foregoing S104.

[0197] The foregoing S702 - S704 may be executed by the server 72.

[0198] In an implementable manner, a public method may be preset to obtain reference response data, and the public method may include the following code example.

[0199] public class BaseResponseGenerator {

[0200] public static Map<String, String> generateProductInfoResponse(Exception e) {

[0201] Map<String, String> baseResponse = new HashMap<>();

[0202] baseResponse.put("productId", "unknown");

[0203] baseResponse.put("productName", "default product");

[0204] baseResponse.put("price", "100.00");

[0205] baseResponse.put("description", "default description");

[0206] if (e instanceof DataNotFoundException) {

[0207] / / Additional handling logic for data fetching exception

[0208] } else if (e instanceof TimeoutException) {

[0209] / / Additional handling logic for timeout exception

[0210] } else if (e instanceof InternalServerException) {

[0211] / / Additional handling logic for internal server exception

[0212] }

[0213] return baseResponse;

[0214] }

[0215] public static Map<String, String> generateUserInfoResponse(Exception e) {

[0216] Map<String, String> baseResponse = new HashMap<>();

[0217] baseResponse.put("userId", "unknown");

[0218] baseResponse.put("userName", "defaultUser");

[0219] baseResponse.put("email", "default@example.com");

[0220] baseResponse.put("address", "default address");

[0221] if (e instanceof DataNotFoundException) {

[0222] / / Additional handling logic for data fetching exception

[0223] } else if (e instanceof TimeoutException) {

[0224] / / Additional handling logic for timeout exception

[0225] } else if (e instanceof InternalServerException) {

[0226] / / Additional handling logic for internal server exception

[0227] }

[0228] return baseResponse;

[0229] }

[0230] public static Map<String, String> generateOrderStatusResponse(Exception e) {

[0231] Map<String, String> baseResponse = new HashMap<>();

[0232] baseResponse.put("orderId", "unknown");

[0233] baseResponse.put("orderStatus", "processing");

[0234] baseResponse.put("estimatedDelivery", "not available");

[0235] if (e instanceof DataNotFoundException) {

[0236] / / Additional handling logic for data retrieval exceptions

[0237] } else if (e instanceof TimeoutException) {

[0238] / / Additional handling logic for timeout exceptions

[0239] } else if (e instanceof InternalServerException) {

[0240] / / Additional handling logic for internal server exceptions

[0241] }

[0242] return baseResponse;

[0243] }

[0244] }

[0245] Among them, the BaseResponseGenerator (benchmark response data generation method) can include three sub - methods, the generateProductInfoResponse(Exception e) method (product information benchmark response data generation method), the generateUserInfoResponse(Exception e) method (user information benchmark response data generation method), and the generateOrderStatusResponse(Exception e) (order information benchmark response data generation method). These sub - methods correspond to the product information business, user information business, and order information query business respectively. They are respectively used to obtain benchmark response data when the business identifier included in the received target request indicates the product information business, user information business, and order information query business.

[0246] In the generateProductInfoResponse(Exception e) method, the baseResponse (benchmark response data) is defined, and the put() method (the method for adding key-value pairs) is used to set preset values for the baseResponse. Through the if...else... method (conditional judgment method), for different exception types satisfied by the obtained Exception e (exception e), when the exception type of this exception is DataNotFoundException (data acquisition exception) or TimeoutException (timeout exception) or InternalServerException (internal server exception), different additional processing logics are executed respectively, and the benchmark response data is returned.

[0247] In the generateUserInfoResponse(Exception e) method, the baseResponse (benchmark response data) is defined, and the put() method (the method for adding key-value pairs) is used to set preset values for the baseResponse. Through the if...else... method (conditional judgment method), for different exception types satisfied by the obtained Exception e (exception e), when the exception type of this exception is DataNotFoundException (data acquisition exception) or TimeoutException (timeout exception) or InternalServerException (internal server exception), different additional processing logics are executed respectively, and the benchmark response data is returned.

[0248] In the generateOrderStatusResponse(Exception e) method, the baseResponse (benchmark response data) is defined, and the put() method (the method for adding key-value pairs) is used to set preset values for the baseResponse. Through the if...else... method (conditional judgment method), for different exception types satisfied by the obtained Exception e (exception e), when the exception type of this exception is DataNotFoundException (data acquisition exception) or TimeoutException (timeout exception) or InternalServerException (internal server exception), different additional processing logics are executed respectively, and the benchmark response data is returned.

[0249] The embodiments of the present invention do not limit the specific form of the additional processing logic.

[0250] Using the above code example, taking the commodity information query service as an example, after the server receives a commodity query request, it can first attempt to obtain the detailed commodity information from the database, that is, respond to the commodity query request.

[0251] If there is no exception, directly return the obtained data.

[0252] If an exception occurs, when the exception type is data acquisition exception (such as database connection failure), use the generateProductInfoResponse method to obtain the baseline response data and return it; when the exception type is timeout exception, first obtain the cached response data, if there is no cached response data, then call the generateProductInfoResponse method to obtain the baseline response data and return it; when the exception type is internal server exception, call the generateProductInfoResponse method to obtain the baseline response data, modify the error content and return it.

[0253] The embodiment of the present invention can generate and return corresponding baseline response data for different services and exception types, ensuring that the server can return relatively reasonable response data to the request end in case of an exception, so that the request end can maintain the availability of the basic service based on these data.

[0254] The embodiment of the present invention provides a request response device, which is applied to the server, such as Figure 8 shown, the device may include:

[0255] A receiving module 801, configured to receive a target request sent by a request end;

[0256] An exception detection module 802, configured to perform exception detection on the response of the target request;

[0257] A baseline response data obtaining module 803, configured to obtain pre-generated baseline response data or generate baseline response data in real time when an exception is detected; the baseline response data is used to implement the basic functions of the service corresponding to the business type of the target request, and the basic functions are used to ensure the availability of the service; wherein, the baseline response data includes at least one data pair corresponding to a preset data type, and each data pair includes a data identifier of the preset data type and the corresponding data value;

[0258] A return module 804, configured to return the baseline response data to the request end.

[0259] Optionally, the target request includes a service identifier;

[0260] The reference response data acquisition module 803 is specifically configured to: acquire the reference response data corresponding to the service identifier pre-configured in the configuration file or component; or, call a preset function to generate the reference response data corresponding to the service identifier.

[0261] Optionally, the apparatus further includes:

[0262] A judgment module, configured to judge whether there is response data corresponding to a historical request identical to the target request stored in the cache before acquiring the pre-generated reference response data or generating the reference response data in real time;

[0263] The reference response data acquisition module 803 is specifically configured to, if it is judged that there is no response data corresponding to a historical request identical to the target request stored in the cache, acquire the pre-generated reference response data or generate the reference response data in real time.

[0264] Optionally, the apparatus further includes:

[0265] A determination module, configured to, if it is judged that there is response data corresponding to a historical request identical to the target request stored in the cache, use the response data corresponding to the historical request as the reference response data corresponding to the target request.

[0266] Optionally, the apparatus further includes:

[0267] A first acquisition module, configured to, after acquiring the pre-generated reference response data or generating the reference response data in real time, acquire the request real-time response data, where the request real-time response data is the result obtained by the processing end for processing the target request, and the processing end is the one in the server for processing requests;

[0268] A search module, configured to search for the data type identifier with the data value being the preset invalid field in the request real-time response data as the target data type identifier;

[0269] A comparison module, configured to compare the target data type identifier with the data identifiers of each preset data type in the reference response data, and use the data value corresponding to the data identifier identical to the target data type identifier in the reference response data as the data value corresponding to the target data type identifier;

[0270] A combination module, configured to combine the data value corresponding to the target data type identifier and the data values corresponding to other data type identifiers in the request real-time response data as the reference response data corresponding to the target request, where the other data type identifiers represent data type identifiers other than the target data type identifier.

[0271] Optionally, the apparatus further includes:

[0272] A second acquisition module, configured to, after acquiring pre-generated reference response data or generating reference response data in real time, acquire data obtained by other preset methods, where the other preset methods include preset methods other than the preset method with an exception among multiple preset methods, and a processing end for processing requests in the server processes a target request through multiple preset methods, and the preset method with an exception means that an exception is detected when processing the target request by using the preset method;

[0273] A modification module, configured to modify the reference response data based on the data obtained by other preset methods to obtain modified reference response data.

[0274] Optionally, the modification module is specifically configured to, for each data identifier of a preset data type in the reference response data, search whether there is a data type in the data obtained by other preset methods that has the same meaning as the data identifier; if so, modify the data value corresponding to the data identifier in the reference response data to the data value corresponding to the data type that has the same meaning as the data identifier in the data obtained by other preset methods.

[0275] Optionally, the exception detection module 802 is specifically configured to execute a preset exception check logic and capture the execution result; based on the execution result, search for the corresponding relationship between the preset execution result and the exception type, and determine the exception type to which the exception belongs.

[0276] An embodiment of the present invention further provides an electronic device, as Figure 9 shown, including a processor 901, a communication interface 902, a memory 903, and a communication bus 904, where the processor 901, the communication interface 902, and the memory 903 complete communication with each other through the communication bus 904;

[0277] The memory 903 is used to store a computer program;

[0278] The processor 901, when executing the program stored on the memory 903, implements the above request response method.

[0279] The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity, only a thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus.

[0280] The communication interface is used for communication between the above terminal and other devices.

[0281] The memory may include a Random Access Memory (RAM), or may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0282] The aforementioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0283] In another embodiment provided by the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the request response method described in any one of the above embodiments is implemented.

[0284] In another embodiment provided by the present invention, there is also provided a computer program product containing instructions, and when it runs on a computer, it causes the computer to execute the request response method described in any one of the above embodiments.

[0285] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes one or more integrated available media. The available media can be magnetic media (such as floppy disks, hard disks, magnetic tapes), optical media (such as DVDs), or semiconductor media (such as solid state disks (SSDs)).

[0286] It should be noted that in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.

[0287] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the apparatus, electronic device, computer-readable storage medium, and computer program product, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments.

[0288] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included within the protection scope of the present invention.

Claims

1. A request response method, characterized in that: Applied to the server, the method includes: Receive the target request sent by the requester; Performing anomaly detection on the response to the target request; When an abnormality is detected, pre-generated benchmark response data is obtained, or benchmark response data is generated in real time; the benchmark response data is used to implement the basic function of the service of the business type corresponding to the target request, and the basic function is used to ensure the availability of the service; wherein the benchmark response data includes at least one data pair corresponding to a preset data type, and each data pair includes a data identifier of the preset data type and a corresponding data value; The reference response data is returned to the requesting end.

2. The method according to claim 1, characterized in that The target request includes a service identifier; The obtaining of pre-generated benchmark response data includes: Obtaining the reference response data corresponding to the service identifier pre-configured in the configuration file or component; or, The real-time generation of benchmark response data includes: A preset function is called to generate reference response data corresponding to the service identifier.

3. The method according to claim 1, characterized in that Before obtaining the pre-generated benchmark response data, or generating the benchmark response data in real time, the method further includes: determining whether the cache stores response data corresponding to a historical request identical to the target request; The obtaining of pre-generated benchmark response data, or generating benchmark response data in real time, includes: If it is determined that the cache does not store response data corresponding to the historical request identical to the target request, pre-generated reference response data is obtained, or reference response data is generated in real time.

4. The method according to claim 3, characterized in that The method further comprises: If it is determined that response data corresponding to a historical request identical to the target request is stored in the cache, the response data corresponding to the historical request is used as reference response data corresponding to the target request.

5. The method according to claim 1, characterized in that After obtaining the pre-generated benchmark response data, or generating the benchmark response data in real time, the method further includes: Acquire request real-time response data, where the request real-time response data is a result obtained by a processing end for processing the target request, and the processing end is a part of the server end for processing the request; Searching for a data type identifier whose data value is a preset invalid field in the real-time response data of the request as a target data type identifier; Compare the target data type identifier with the data identifiers of each preset data type in the reference response data, and use the data value corresponding to the data identifier in the reference response data that is the same as the target data type identifier as the data value corresponding to the target data type identifier; The data value corresponding to the target data type identifier and the data values ​​corresponding to other data type identifiers in the request real-time response data are combined as the benchmark response data corresponding to the target request, and the other data type identifiers represent data type identifiers other than the target data type identifier.

6. The method according to claim 1, characterized in that After obtaining the pre-generated benchmark response data, or generating the benchmark response data in real time, the method further includes: Acquire data obtained by other preset methods, wherein the other preset methods include preset methods other than the preset method with an exception among the multiple preset methods, the processing end for processing the request in the server jointly processes the target request by using multiple preset methods, and the preset method with an exception indicates that an exception is detected when the target request is processed by the preset method; The reference response data is modified based on the data obtained by the other preset method to obtain modified reference response data.

7. The method according to claim 6, characterized in that The step of modifying the reference response data based on the data obtained by the other preset method to obtain modified reference response data includes: For each data identifier of a preset data type in the benchmark response data, searching whether the data obtained by the other preset methods has a data type with the same meaning as the data identifier; If yes, the data value corresponding to the data identifier in the benchmark response data is modified to the data value corresponding to the data type having the same meaning as the data identifier in the data obtained by the other preset method.

8. The method according to claim 1, characterized in that The performing abnormality detection on the response to the target request includes: Execute the preset exception check logic and capture the execution results; Based on the execution result, the corresponding relationship between the preset execution result and the exception type is found to determine the exception type to which the exception belongs.

9. A request response device, characterized in that: Applied to the server, the device comprises: A receiving module, used for receiving a target request sent by a requesting end; An anomaly detection module, used for performing anomaly detection on the response to the target request; A benchmark response data acquisition module, used to obtain pre-generated benchmark response data when an abnormality is detected, or to generate benchmark response data in real time; the benchmark response data is used to implement the basic function of the service of the business type corresponding to the target request, and the basic function is used to ensure the availability of the service; wherein the benchmark response data includes at least one data pair corresponding to a preset data type, and each data pair includes a data identifier of the preset data type and a corresponding data value; The returning module is used to return the reference response data to the requesting end.

10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the steps of any method described in claims 1-8 when executing a program stored in a memory.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 8 are implemented.