Service call exception handling and component injection method, device, storage medium and program product

By using a component-based service call management component to intercept and handle exceptions, the problem of excessively long response times or failures in service calls is solved, resulting in more stable service operation and user experience.

CN123157486APending Publication Date: 2026-11-24ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510660451.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-21
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

In cross-system or microservice collaboration, service calls often experience excessively long response times or call failures, resulting in overall response times exceeding expectations and impacting service quality and user experience.

Method used

The exception handling logic is componentized into a service call management component. It intercepts service call requests, and if a weak dependency service characteristic is detected and an exception occurs, it is handled according to the exception handling strategy and an exception response message is returned so that the service caller can continue to run.

Benefits of technology

By using component-based exception handling and weakly dependent services, the overall service call duration can be controlled, timeout errors can be reduced, and service quality and user experience can be improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123157486A_ABST
    Figure CN123157486A_ABST
Patent Text Reader

Abstract

This application provides a service call exception handling and component injection method, device, storage medium, and program product. In this application, on the one hand, exception handling logic is componentized into general-purpose and reusable components; on the other hand, for the service initiating the call, the weak dependency service feature is enabled on demand. The component intercepts the call request to the service. If the service has the weak dependency service feature enabled and an exception is detected during the service call process, the exception is handled according to the service's corresponding exception handling strategy, and an exception handling response message is returned so that the service caller can continue running. By combining the component with exception handling logic and the on-demand enabled weak dependency service feature, exceptions are handled, the overall service call duration is controlled, timeout errors are reduced, and service quality and user experience are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of service invocation technology, and in particular to a service invocation exception handling and component injection method, device, storage medium and program product. Background Technology

[0002] With the development of technologies such as cloud computing and microservices, cross-system collaboration and inter-microservice collaboration have become key technical means to realize complex functional logic and improve system flexibility and scalability. Whether it's cross-system or inter-microservice collaboration, its essence lies in enabling one service to call another service to complete a specific function through standardized interfaces and service contracts. This collaboration model not only ensures the modularity and decoupling of the system but also improves the maintainability and scalability of the overall architecture.

[0003] However, in practical applications, when one service calls another, issues such as excessively long response times or call failures frequently occur. This situation can cause the overall response time of the calling service to exceed expectations, or even trigger timeout errors, severely impacting the service quality and user experience. Summary of the Invention

[0004] This application provides a service call exception handling and component injection method, device, storage medium, and program product to handle service call exceptions, control the overall call duration of the service caller, reduce the occurrence of timeout errors, and thereby improve the service quality and user experience.

[0005] This application provides a service call exception handling method, applied to a service call management component in a target application. The service call management component is obtained by modularizing the exception handling logic during the service call process. The method includes: intercepting the call request initiated by the target application to a target service during runtime, and initiating the call to the target service on behalf of the target application. The target service is any service that the target application can call. If the target service has a weak dependency service feature enabled, and an exception is detected during the call process of the target service, the exception is handled according to the exception handling strategy corresponding to the target service, and an exception handling response message is returned to the target application so that the target application can continue to run when the target service call is abnormal. The weak dependency service feature is a service feature that does not affect the continued operation of the service caller when the service call is abnormal.

[0006] This application also provides a component injection method, including: implementing exception handling logic in the service call process in a componentized manner to obtain a service call management component; introducing the service call management component into a target application in the form of a resource library; configuring the service call management component to act as a functional component in the target application to provide exception handling services in the service call process for the target application.

[0007] This application also provides an electronic device, including a memory and a processor. The memory is used to store a computer program, and the processor is coupled to the memory to execute the computer program to implement the steps in the various methods provided in this application.

[0008] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to perform the steps in the methods described above.

[0009] This application also provides a computer program product, which includes a computer program / instructions that, when executed by a processor, enable the processor to implement the steps described in the above method embodiments.

[0010] In this embodiment, on the one hand, the exception handling logic is modularized into components with generality and reusability; on the other hand, for the service initiating the call, the weak dependency service feature is enabled on demand. The component intercepts the call request initiated by the service. If the service has the weak dependency service feature enabled and an exception is detected in the service call process, the exception is handled according to the service's corresponding exception handling strategy, and an exception handling response message is returned so that the service caller can continue to run. By combining the component with exception handling logic and the on-demand enabled weak dependency service feature, exceptions are handled, the overall call duration of the service is controlled, timeout errors are reduced, and service quality and user experience are improved. Attached Figure Description

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

[0012] Figure 1 A flowchart illustrating a service call exception handling method provided in an exemplary embodiment of this application;

[0013] Figures 2-4 This is an interactive schematic diagram of a service call exception handling method in another exemplary embodiment of this application;

[0014] Figure 5 A flowchart illustrating a component injection method provided for an exemplary embodiment of this application;

[0015] Figure 6 This is a schematic diagram of the structure of an electronic device provided as another exemplary embodiment of this application. Detailed Implementation

[0016] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0017] It should be noted that, in the cases involving user information in the embodiments of this application, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse. In addition, the various models involved in this application (including but not limited to language models or large models) comply with relevant laws and standards.

[0018] When cloud providers offer services, they can output cloud services as a cloud service system. A cloud service system can include multiple subsystems, and these subsystems can collaborate across systems through standardized interfaces, enabling services in one subsystem to call services in another subsystem, thereby providing relatively complete functionality.

[0019] In one example, the cloud service system includes an instance provisioning system and an instance billing system, but is not limited to these. The instance provisioning system depends on the instance billing system, and the instance provisioning system needs to call the billing services within the instance billing system to achieve a closed loop of on-demand resource production and resource management.

[0020] However, when a service in one subsystem calls a service in another subsystem, issues such as excessively long response times or call failures frequently occur. This situation can cause the overall response time of the service acting as the caller to exceed expectations, or even trigger timeout errors, severely impacting the service quality and user experience.

[0021] To address the issues of excessively long or failed service calls, resulting in unexpected overall service response times and even timeout errors, this application embodiment addresses these problems by: firstly, componentizing exception handling logic into general and reusable components; and secondly, enabling on-demand weak dependency service features for the initiating service. The component intercepts service call requests; if the service has weak dependency features enabled and an exception is detected during the call process, it handles the exception according to the service's corresponding exception handling strategy and returns an exception handling response message, allowing the service caller to continue running. By combining components with exception handling logic and on-demand weak dependency service features, exceptions are handled, controlling the overall service call duration, reducing timeout errors, and ultimately improving service quality and user experience.

[0022] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.

[0023] This application provides a service call exception handling method, which is applied to a service call management component in a target application. Any software program, system, or functional module that needs to call other services can be implemented as the target application in this application. In some embodiments, the target application can refer to an application developed based on a microservice architecture, but is not limited thereto. The microservice architecture can break down the target application into independent services, each undertaking corresponding functions, with services depending on and calling each other to achieve complex functional logic.

[0024] In this embodiment, the dependencies between services have varying degrees of strength. Based on the strength of the dependency, these dependencies can be categorized into strong service dependency relationships and weak service dependency relationships. A weak service dependency refers to a service feature where a service call failure does not affect the continued operation of the service caller. Conversely, a strong service dependency refers to a service call failure that directly causes the service caller to become unavailable. This embodiment focuses on weak service dependency relationships.

[0025] In this embodiment, a service call management component is pre-injected into the target application, and the aforementioned service call exception handling method can be applied to this service call management component. The service call management component is a componentized version of the exception handling logic. It is responsible for providing services to the target application, including call management services and exception handling services. The call management service primarily refers to the target application initiating a call to the service through the service call management component, rather than directly initiating a call to the service. In other words, the call path from the target application to the service forms the path: target application → service call management component → service. Based on this, when the service call path passes through the service call management component, the service call management component has the foundation to provide exception handling services for the target application in case of service call exceptions. It should be understood that this is a brief description of the path where the target application calls the service through the service call management component; this embodiment does not limit whether other execution entities are involved in the call path.

[0026] Furthermore, such as Figure 1 As shown, the service call exception handling methods applied to the service call management component include:

[0027] S101: Intercept the call request initiated by the target application to the target service during the running process, and make the call to the target service on behalf of the target application. The target service is any service that the target application can call.

[0028] S102: If the target service has enabled the weak dependency service feature and an abnormal situation is detected in the call process of the target service, the abnormal situation is handled according to the corresponding exception handling strategy of the target service, and an exception handling response message is returned to the target application so that the target application can continue to run when the target service call is abnormal; wherein, the weak dependency service feature is a service feature that does not affect the continued operation of the service caller when the service call is abnormal.

[0029] In this embodiment, the service invocation management component is obtained by modularizing the exception handling logic in the service invocation process. The exception handling logic refers to the code logic that handles exceptions when an abnormal situation occurs during the invocation process of the target service.

[0030] In this embodiment, componentization refers to dividing the exception handling logic into several independent, reusable components according to their functions. Each component encapsulates its own functions, data, and interaction logic. In this embodiment, the service call management component is a component obtained by componentizing the exception handling logic. The number of components can be one or more. In the case of multiple components, the service call management component can provide exception handling services as a whole. For example, multiple service call management components can be implemented as a service product, such as being encapsulated as an SDK (Software Development Kit) component, but are not limited to this.

[0031] In this embodiment, the service invocation management component is responsible for intercepting invocation requests initiated by the target application, initiating invocations to the target service on behalf of the target application, and handling exceptions when invocation exceptions occur. Here, the target service refers to any service that the target application can invoke.

[0032] In this embodiment, the weak dependency service characteristic is a service characteristic that can be enabled on demand. Specifically, it refers to a service characteristic where a service call failure does not affect the continued operation of the service caller. If the target service has the weak dependency service characteristic enabled, then even if a call to the target service fails, the service caller will still be able to continue running. For example, consider service A as the target service and service B as the service caller. Service B depends on service A. If service A has the weak dependency service characteristic enabled, even if service B encounters an exception when calling service A, service B can still continue running.

[0033] Furthermore, if an anomaly is detected, it is handled according to the exception handling policy corresponding to the target service, and an exception handling response message is returned to the target application, enabling the target application to continue running even when the target service call fails. In other words, exception handling can prevent the target application from crashing or generating other errors, improving the robustness of the program, making the application more robust, and able to cope with various unexpected exceptions, thereby improving service quality and user experience.

[0034] In this embodiment, on the one hand, the exception handling logic is modularized into components with generality and reusability; on the other hand, for the service initiating the call, the weak dependency service feature is enabled on demand. The component intercepts the call request initiated by the service. If the service has the weak dependency service feature enabled and an exception is detected in the service call process, the exception is handled according to the service's corresponding exception handling strategy, and an exception handling response message is returned so that the service caller can continue to run. By combining the component with exception handling logic and the on-demand enabled weak dependency service feature, exceptions are handled, the overall call duration of the service is controlled, timeout errors are reduced, and service quality and user experience are improved.

[0035] In this embodiment, the exception handling logic can be componentized to obtain a service call management component. This component is pre-introduced into the target application to provide call management and exception handling services. The call management service primarily refers to the target application initiating calls to services through the service call management component. In other words, the service call management component intercepts call requests initiated by the target application to the target service during runtime and initiates the calls on behalf of the target application. The exception handling service provided by the service call management component can handle exceptions when abnormal conditions occur in the target service and return an exception handling response message to the target application, ensuring that the service does not affect the continued operation of the caller.

[0036] Optionally, when providing call management services, the service call management component can intercept call requests initiated to the target service and then initiate a call to the target service on behalf of the service caller. This allows the service call management component to handle exceptions occurring in the target application when a service call fails. Based on this, in an optional embodiment, intercepting call requests initiated by the target application to the target service during runtime and initiating the call on behalf of the target application includes: intercepting the call requests initiated by the target application to the target service during runtime; submitting the call requests to a target thread pool, which includes a specified number of threads; allocating idle threads from the specified number of threads for the call requests; and using the allocated threads to initiate a call to the target service. The specified number of threads can be multiple.

[0037] In this embodiment, an idle thread is allocated from a specified number of threads for the call request, and the allocated idle thread is used to initiate a call to the target service. This allows the call to the target service to be executed asynchronously through the allocated idle child thread without blocking the main thread, thereby improving the overall responsiveness and efficiency of the application.

[0038] In one optional embodiment, before submitting the call request to the target thread pool, the method further includes: using the default thread pool in the service call management component as the target thread pool; or, in response to a thread pool configuration operation initiated by the target application through the thread pool configuration interface provided by the service call management component, using the thread pool configured by the target application as the target thread pool.

[0039] In this embodiment, the thread pool configuration interface is a configuration interface exposed by the service invocation management component to the application. This allows the application to initiate thread pool configuration operations and configure a thread pool as the target thread pool by calling the thread pool configuration interface. If the application has not configured a thread pool, the default thread pool of the service invocation management component will be used as the target thread pool. Through different thread pool configuration strategies, flexible selection and dynamic configuration of the thread pool can be achieved, enabling efficient allocation of thread resources and improving concurrency processing capabilities. In addition, the service invocation management component also provides various other configuration interfaces to the application, allowing the application to flexibly execute various configuration operations through these other interfaces.

[0040] In this embodiment, the method of intercepting the call requests initiated by the target application to the target service during runtime and initiating the call to the target service on behalf of the target application is not limited. For example, it can be implemented based on AOP (Aspect-Oriented Programming). AOP refers to a programming paradigm that weaves code logic into the target objects of an application in a non-intrusive manner. The target objects can be, but are not limited to, specified locations of specified methods, various components, etc. In this embodiment, various components can be implemented as service call management components.

[0041] In this embodiment, the target thread pool is implemented as an asynchronous thread pool, but it is not limited to this. In other embodiments, the target thread pool can also be implemented as a synchronous thread pool. The following description uses the implementation of the target thread pool as an asynchronous thread pool as an example.

[0042] In this embodiment, when the target thread pool is implemented as an asynchronous thread pool, the asynchronous thread pool includes a specified number of child threads for exception execution of call requests submitted by the main thread. Each child thread can be responsible for asynchronously executing one call request. Asynchronous execution means that after submitting a call request, the main thread does not wait for the call result but immediately continues executing its own code logic. In this embodiment, when the main thread submits a call request for the target service, an idle child thread is allocated from the specified number of threads for the call request, and the allocated child thread is used to initiate the call to the target service. This allows for asynchronous execution of the call to the target service through the allocated idle child threads without blocking the main thread, improving the overall responsiveness and efficiency of the application.

[0043] In this embodiment, when there are no idle threads in the asynchronous thread pool to handle the call request, the main thread can continue executing the original logic of the target service. In this case, the weak dependency characteristic of the target service fails. Alternatively, a fallback operation can be triggered. The fallback operation, if it detects an anomaly during the service call, returns to the previous state, thus ensuring data consistency.

[0044] In this embodiment, the service invocation management component is a component derived from the componentization of exception handling logic. The exception handling logic includes exception handling strategies for various exception situations. Each type of exception situation has a corresponding exception handling strategy that can be used to handle that exception situation and return an exception handling response message to the target application, enabling the target application to continue running even when the target service invocation fails. In an optional embodiment, the types of exception situations include, but are not limited to, timeout exceptions, original logic exceptions, and fast failure exceptions. Different exception situations can be handled using different exception handling strategies, thereby enabling flexible configuration of exception handling strategies to adapt to various application scenarios.

[0045] Among them, the timeout exception refers to the exception that the call to the target service is not completed within the timeout period; the original logic exception refers to the exception that occurs during the call to the target service; the fail-fast exception refers to the exception that occurs when the target service fails and becomes unavailable. In the fail-fast exception case, the actual call to the target service may not be executed.

[0046] The detection logic for timeout exceptions differs from that for other exceptions. The timeout exception detection logic is implemented through the service call management component, which is a component derived from the exception handling logic. This exception handling logic includes timeout exception detection logic, which is executed by the service call management component to check whether the call to the target service was completed within the timeout period corresponding to the target service.

[0047] Based on this, in an optional embodiment, detecting whether an abnormal situation occurs during the call process of the target service includes: when a call is initiated to the target service, creating a timeout detection task, which is used to detect whether the call to the target service is completed within the timeout period corresponding to the target service; if it is detected that the call to the target service is not completed within the timeout period, it is determined that a timeout abnormal situation has occurred during the call process of the target service. Through the timeout detection task, the call duration can be monitored and timeout controlled in real time, enabling proactive triggering of the detection of timeout abnormal situations and improving the ability to identify abnormal situations.

[0048] In this embodiment, the algorithm for timeout detection is not limited. For example, it can be, but is not limited to, "HashedWheelTimer (a time wheel-based timer)," which can manage timeout detection tasks in a more efficient way.

[0049] It should be noted that other anomalies will be automatically detected. These other anomalies include, but are not limited to, primitive logic anomalies and fast failure anomalies.

[0050] In this embodiment, the call request is submitted to the target thread pool, and then an idle thread is allocated from a specified number of threads to initiate a call to the target service. When a call is initiated to the target service, a timeout detection task is created to check whether the call to the target service completes within the corresponding timeout period. The timeout period can be set as needed; different target services may have the same or different timeout periods, and this is not limited. If the timeout period for the target service is detected to have expired, and the call to the target service has not yet completed, a timeout exception can be determined.

[0051] In one optional embodiment, if an abnormal situation occurs during the call process of the target service, exception information can be output. Accordingly, in this embodiment, when handling the exception situation according to the exception handling strategy corresponding to the target service, the process includes: identifying the type of exception situation based on the exception information; and handling the exception situation using an exception handling strategy adapted to the type of exception situation.

[0052] In this embodiment, different types of exceptions will result in different output exception information. By identifying different exception types, the specific cause of the exception can be quickly located, allowing for the application to adopt an appropriate exception handling strategy to prevent application crashes and ensure the target application continues to run even when service calls encounter exceptions. For example, when detecting a timeout exception during a call to the target service, a "PredictedTimeoutException" exception can be output. Similarly, when detecting a rapid identification exception during a call to the target service, a "WeakCallableFailFastException" exception can be output.

[0053] The exception handling logic includes exception handling strategies for various exception situations. Each type of exception situation has a corresponding exception handling strategy that can be used to handle that exception situation. The service call management component obtained through the componentized exception handling logic can adopt an exception handling strategy that is adapted to the type of exception situation to handle the exception situation.

[0054] Optionally, when handling exceptions using an exception handling strategy adapted to the type of exception, the process includes: if the exception type is a timeout exception, terminating the call to the target service and triggering a rollback operation to handle the timeout exception; if the exception type is a primary logic exception, triggering a rollback operation to handle the primary logic exception; and if the exception type is a fast failure exception, triggering a rollback operation to handle the fast failure exception. By executing exception handling strategies adapted to different types of exceptions, the flexibility of exception handling strategy configuration is improved, as is the stability of the continued operation of the service caller.

[0055] In this embodiment, the timeout exception handling strategy includes: if the exception type is a timeout exception, terminating the call to the target service and triggering a rollback operation to handle the timeout exception; the fast failure exception strategy includes: if the exception type is a fast failure exception, triggering a rollback operation to handle the fast failure exception; and the original logic exception handling strategy includes: if the exception type is an original logic exception, triggering a rollback operation to handle the original logic exception.

[0056] In this embodiment, the code implementation of the exception handling strategy is not limited. In some embodiments, the code implementation of the exception handling strategy is related to the programming language used by the target application. The following describes the code implementation of the exception handling strategy in conjunction with the Java programming language, but this does not constitute a limitation on the programming language used in this embodiment or the code implementation of the exception handling strategy.

[0057] In Java, exception handling strategies can be implemented using the try-catch structure. A try-catch structure consists of a try block and a catch block. First, the code in the try block is executed. If an exception occurs during the execution of the code in the try block, an exception is thrown (an example of outputting exception information) to confirm that an exception has occurred. Then, when an exception is thrown in the try block, execution jumps to the catch block. The exception type can be identified based on the exception information; subsequently, an exception handling strategy appropriate to the exception type is adopted to handle the exception. Each catch block can be associated with a specific exception type. When an exception is thrown in the try block, the associated catch block is matched based on the identified exception type, and then the catch block associated with that exception type is executed to handle the exception.

[0058] The above embodiments introduced various abnormal situations and their corresponding exception handling strategies. The following describes how to componentize the exception handling logic during service calls to obtain a service call management component, and the working principle of the service call management component.

[0059] In one optional embodiment, the service invocation management component is introduced into the target application as a resource library, and configured to act as a functional component within the target application, providing exception handling services during the service invocation process. Optionally, the service invocation management component can be encapsulated as an SDK (Software Development Kit) component.

[0060] In this embodiment, the service invocation management component implements the componentization of exception handling logic. This componentization is achieved by writing code, encapsulating the code logic into an SDK, and adding it to the resource library upon which the target application depends. This SDK serves as a library function, providing exception handling services during the service invocation process for the target application. By introducing the componentized service invocation management component into the resource library, reuse of the service invocation management component is achieved. Reusing components from the resource library significantly reduces repetitive coding and accelerates the application development process. Optionally, the resource library can be a first-party, second-party, or third-party resource library; there is no limitation on this. The terms "first-party," "second-party," or "third-party resource library" are defined from the perspective of the target application's developer. A first-party resource library refers to one developed by the team developing the target application; a second-party resource library refers to one developed by teams developing other applications under that developer; and a third-party resource library refers to one developed by a developer other than the target application's developer.

[0061] Optionally, when configuring the role of the service invocation management component within the target application's functional components to provide exception handling services during the service invocation process, the configuration includes: adding a component identifier to the service invocation management component using annotations, and instructing the target application to add the service invocation management component as a functional component based on the component identifier; and enabling weak dependency service features for at least one service that the target application can invoke within the service invocation management component, so that the service invocation management component can provide exception handling services during the service invocation process for the target application. Introducing the service invocation management functional component into the target application using annotations does not intrude on the target application's original code logic, thus improving the maintainability and extensibility of the functional component.

[0062] In one optional embodiment, when adding a component identifier to the service invocation management component using annotations, the component identifier can be added to the target application's list of functional components, thereby instructing the target application to add the service invocation management component as a functional component based on the component identifier. Further optionally, instructing the target application to add the service invocation management component as a functional component based on the component identifier includes: adding a weak dependency import component identifier to the service invocation management component using annotations, declaring the import of weak dependency service features, and instructing the scan for service invocation management components with the component identifier based on the weak dependency import component identifier, and injecting supporting weak dependency service features to add the service invocation management component as a functional component of the target application.

[0063] In this embodiment, annotations enable automatic scanning and injection of weakly dependent service features, simplifying the configuration process, automating the management of weakly dependent service features, and improving development efficiency, configuration flexibility, and code maintainability.

[0064] It should be noted that the detailed implementation of the above annotation method is related to the development framework, and different development frameworks support different annotation methods. In one example, taking the Spring development framework, the above component identifier can be implemented as "WeakCallComponent". By annotating the component class with this component identifier, it is declared that the component class is a component class related to the implementation of weak dependency service features (i.e., service call management component). When the Spring container has enabled the scanning operation of component identifiers, it can scan for the component identifier and inject the component class with the component identifier into the Spring container, thereby realizing the componentization of the component class, that is, adding it as a functional component.

[0065] Furthermore, continuing from the example above, in Spring's configuration class, a weak dependency component identifier can be configured. In the Spring development framework, this identifier can be implemented as "ImportWeakCallComponent". It should be understood that this weak dependency component identifier is an example provided to adapt to the Spring development framework's annotation-based approach, but the annotation method in this embodiment is not limited to the Spring framework. In this example, the code logic of the `ImportWeakCallComponent` annotation can be custom-implemented in the `ImportBeanDefinitionRegistrar` function. This function automatically scans the code of the aforementioned service call management component and injects the code supporting the weak dependency service feature into the Spring container, making the component identifier "WeakCallComponent" effective.

[0066] Optionally, in the service invocation management component, the weak dependency service feature is enabled for at least one service that the target application can invoke, including: using the function in the service invocation management component used to enable the weak dependency service feature as an entry function, the entry function being associated with a list of weak dependency services, and the services in the list of weak dependency services being accessed through the entry function; adding the identifier of at least one service that the target application can invoke to the list of weak dependency services, thereby enabling the weak dependency service feature for at least one service.

[0067] The above embodiments describe a service invocation management component implemented through code and encapsulated in a resource library as a library function to provide exception handling services during the service invocation process for the target application. The service invocation management component includes a function for enabling weak dependency service characteristics; this function can be called the entry function. The entry function is the starting point for service access in the weak dependency service list, used to identify that each service in the weak dependency service list associated with the entry function possesses the weak dependency service characteristic. By using the function in the service invocation management component that enables weak dependency service characteristics as the entry function, the inheritance of weak dependency service characteristics by each service in the weak dependency service list is achieved, maintaining the consistency of weak dependency service characteristics.

[0068] The weak dependency service list is used to determine which services of the target application need to have the weak dependency service feature enabled. This list can include identifiers for at least one service, each identifier corresponding to a specific service. If a service identifier is present in the weak dependency service list, it means that the weak dependency service feature is enabled for the service corresponding to that identifier. Therefore, the identifiers of at least one service that the target application can call can be added to the weak dependency service list to enable the weak dependency service feature for at least one service. When any service has the weak dependency service feature enabled, the service call management component can provide exception handling services to the target application. By maintaining service identifiers in the weak dependency service list, the on-demand enabling of the weak dependency service feature is achieved, improving the dynamic management capabilities of the weak dependency service feature.

[0069] The function used to enable weak dependency service features can also be called a weak dependency service annotation. Continuing the example above, in the Spring development framework, the weak dependency service annotation can be implemented as "EnableWeakCallable". Using the "EnableWeakCallable" annotation as an entry function enables the weak dependency service feature for the list of weak dependency services associated with that entry function. Furthermore, to enable the weak dependency service feature for any service, it can be annotated with the "WeakCallable" annotation to add that service to the list of weak dependency services, thus enabling the weak dependency service feature for that service.

[0070] Optionally, when intercepting a call request initiated by the target application to the target service during runtime, the process includes: receiving an access request initiated by the target application to the entry function during runtime, the access request including an identifier of the target service; and determining the call request initiated by the target application to the target service based on the identifier of the target service. Then, the service call management component initiates the call to the target service on behalf of the target application. During this process, the service call management component can provide exception handling services to the target application in the event of an exception in the target service call. By identifying the identifier of the target service in the access request, the component can provide targeted exception handling services, offering flexibility and scalability.

[0071] In this embodiment, the service call management component also provides various other configuration interfaces to the application, so that the application can flexibly perform various configuration operations through other configuration interfaces and realize functional expansion.

[0072] In an optional embodiment, the target application can also perform the following operations by calling the configuration interface provided by the management component through the service call:

[0073] In response to the first configuration operation initiated by the target application through the first extended configuration interface provided by the service call management component, and when the weak dependency service feature of the target service is enabled, the effective conditions of the weak dependency service feature of the target service are dynamically configured according to the context information of the current call, the call parameters and / or user information.

[0074] In response to the second configuration operation initiated by the target application through the second extended configuration interface provided by the service call management component, the weak dependency service feature of the target service is turned off or on as needed;

[0075] In addition, in response to the third configuration operation initiated by the target application through the third extended configuration interface provided by the service call management component, the exception handling strategy corresponding to the target service is dynamically configured.

[0076] In this embodiment, the initiated configuration operations, such as the first, second, and third configuration operations, can be configured at the granularity of any service; or, they can be configured at the granularity of a call chain. A call chain describes a directed path constructed according to the order of service calls, recording the complete service call sequence from the starting service (e.g., the entry function) to the ending service. The call chain is pre-constructed based on application logic, and each call chain includes one or more services. The target service can be any service that the target application on the call chain can call. When initiating a configuration operation at the granularity of a call chain, the target call chain containing the target service can be determined based on the identifier of the target service, and a configuration operation can be initiated on the target call chain. The target call chain refers to the call chain containing the target service.

[0077] In this embodiment, weak dependency service granularity features can be configured according to the granularity of services or call chains, thereby enabling flexible control over the configuration granularity of weak dependency service features. This can adapt to various application scenarios and achieve elastic configuration of weak dependency service features.

[0078] In an optional implementation, in response to a first configuration operation initiated by the target application through a first extended configuration interface provided by the service call management component, when the weak dependency service feature of the target service is enabled, and the effective conditions of the weak dependency service feature of the target service are dynamically configured based on the context information of the current call, the call parameters, and / or user information, the effective conditions can be configured in a custom function. This allows for the precise activation of the feature dynamically based on context information, improving the system's context adaptability and flexibility. The context information includes, but is not limited to, the context information of the current call, the call parameters, and / or user information.

[0079] The following is an example of configuring the conditions for the weak dependency service feature to take effect in the Spring development framework, but it is not limited to the Spring development framework.

[0080] In development frameworks such as Spring, various primary extension configuration interfaces are provided. For example, the "EnableWeakCallableCondition" interface is provided. As an example of a primary extension configuration interface, "EnableWeakCallableCondition" allows initiating primary configuration operations. In this example, the "EnableWeakCallableCondition" interface is used to configure the activation conditions in a custom function, making the configuration more flexible and adaptable to various application scenarios. Specifically, the "EnableWeakCallableCondition" interface can configure whether weak dependency service characteristics are enabled. If the exception handling strategy is a timeout exception handling strategy, a timeout detection task can be created to check whether the call to the service is completed within the service's corresponding timeout period.

[0081] For example, the EnableWeakCallableCondition interface controls whether timeout detection is enabled for the call chain involved in a single call request, based on the context information and call parameters of the current call. When timeout detection is enabled for the call chain, the WeakCallable (an example of a list of weakly dependent services) of the services in the call chain can take effect.

[0082] In an optional embodiment, when configuring the activation conditions at the call chain level, the activation conditions of the call chain can be configured in a custom function, but this is not limited to this. The call chain includes, but is not limited to, the call chain for pay-as-you-go purchased instances and the call chain for prepaid purchased instances. For ease of description, "call chain for pay-as-you-go purchased instances" can be abbreviated as "pay-as-you-go call chain," and "call chain for prepaid purchased instances" can be abbreviated as "prepaid call chain."

[0083] In this embodiment, when the weak dependency service feature of the call chain is enabled, the activation conditions of the weak dependency service feature of the call chain can be dynamically configured based on the current call context information, call parameters, and / or user information, so that the weak dependency service feature of the pay-as-you-go call chain takes effect. Here, the call chain is the call chain where the target service resides; the weak service dependency feature of the target service takes effect when the weak dependency service feature of the call chain is enabled. In this embodiment, the activation condition can be configured in a custom function to determine whether the call chain is a pay-as-you-go call chain. Therefore, when the call chain is a pay-as-you-go call chain, the weak dependency service feature can take effect. Optionally, the custom function can be integrated into the target application, and the custom function can be updated through a regular application upgrade.

[0084] When configuring activation conditions at the service level, the activation conditions for any service can be configured in a custom function, but this is not a limitation. In this embodiment, any service is taken as the target service. In this embodiment, when the weak dependency service of the target service is enabled, the activation conditions of the weak dependency service feature of the target service can be dynamically configured based on the context information of the current call, the call parameters, and / or user information, so that the weak dependency service feature of the target service takes effect. For example, the activation condition in the custom function can be configured to determine whether the currently called service is the target service. Therefore, if the currently called service is the target service, the weak dependency service feature can take effect.

[0085] When initiating the first configuration operation through the first extended configuration interface, the effective conditions for the weak dependency service characteristics of the target service can be dynamically configured based on the current call context information, call parameters, and / or user information. The following sections describe the call context information, call parameters, and user information respectively.

[0086] The invocation context refers to the context information related to the invocation request during a single invocation process, including but not limited to attributes related to initiating a call to the target service, such as the invocation address and the identifier of the service caller. The identifier of the service caller can be the identifier of the target application, but is not limited to this. Taking an invocation context including the identifier of the service caller as an example, when dynamically configuring the activation conditions of the weak dependency service characteristic of the target service based on the current invocation context information, the first activation condition includes whether the identifier of the current service caller is the identifier of the target service caller. The identifier of the target service caller can be set as needed; for example, a list of service callers can be maintained, including at least one identifier of the target service caller. If an identifier of a target service caller that matches the identifier of the current service caller is found in the service caller list, the weak dependency service characteristic of the target service takes effect.

[0087] In this embodiment, the call parameters refer to the parameter information provided by the service caller during a single call. When dynamically configuring the effective conditions for the weak dependency service characteristic of the target service based on the current call parameters, the second effective condition includes whether the parameter information received from the service caller is specific parameter information. The specific parameter can be set as needed based on the application scenario.

[0088] In this embodiment, user information refers to the identity identifier of the user who initiates the call during a single call. When dynamically configuring the effective conditions for the weak dependency service characteristic of the target service based on the current user information, the third effective condition includes whether the current user information is the target user information.

[0089] Following the example above, in the Spring development framework, the service call management component provides the "WeakCallABTestAdvisor" interface to determine whether the weak dependency service feature is effective. Service callers can customize the functionality of this interface by implementing it. For example, the interface can be made to determine whether the weak dependency service feature is effective based on the UID (user identifier).

[0090] In this embodiment, the activation conditions of the weak dependency service characteristics of the target service in a single call request can also be controlled simultaneously based on the call context and user information. For example, the call context may include the identifier of the service caller. In this example, the activation conditions of the weak dependency service characteristics of the target service can be dynamically configured based on both the identifier of the service caller and the user information. Specifically, the fourth activation condition includes: determining whether the identifier of the service caller is in the service caller list; if it is in the service caller list, determining whether the current user information is the target user information.

[0091] In this embodiment, the effective conditions of the weak dependency service characteristic of the target service in a single call request can also be controlled simultaneously based on the call context and call parameters. The call context may include the identifier of the service caller. In this example, the effective conditions of the weak dependency service characteristic of the target service can be dynamically configured based on both the identifier of the service caller and the call parameters. Specifically, the fifth effective condition may include: determining whether the identifier of the service caller is in the service caller list; if it is in the service caller list, determining whether the current call parameter is a specific call parameter.

[0092] In the above optional embodiments, the configuration of the activation conditions is described based on different contextual information, such as the call context, call parameters, and user information. When the target service enables the weak dependency service feature, the activation of the weak dependency service feature can be dynamically driven precisely based on the contextual information, improving the system's context adaptability and flexibility.

[0093] The following is an example of configuring the conditions for the weak dependency service feature to take effect in the Spring development framework, but it is not limited to the Spring development framework.

[0094] The Spring development framework provides the "EnableWeakCallableCondition" interface. As an example of the first extended configuration interface, the "EnableWeakCallableCondition" interface can be used to initiate the first configuration operation.

[0095] In this example, the "EnableWeakCallableCondition" interface is used to configure the activation conditions in a custom function, making the configuration more flexible and adaptable to various application scenarios. Specifically, the EnableWeakCallableCondition interface can be used to configure whether timeout detection is enabled.

[0096] For example, the EnableWeakCallableCondition interface controls whether timeout detection is enabled for the call chain involved in a single call request, based on the current call context and call parameters. When timeout detection is enabled for the call chain, the WeakCallable (a list of weakly dependent services) of the services in the call chain can take effect.

[0097] Furthermore, in this embodiment, in response to a second configuration operation initiated by the target application through the second extended configuration interface provided by the service call management component, the weak dependency service feature of the target service is turned off or on as needed. The enabling or disabling of the weak dependency service can be configured at the granularity of any service; or it can be configured at the granularity of the call chain. Optionally, in the case of configuring at the granularity of any service (here, the target service is used as an example), the service caller can read the configuration file and provide it to the service call management component, so that the service call management component can turn off or on the weak dependency service feature of the target service as needed based on the configuration file.

[0098] In this embodiment, by reading the configuration file to determine whether the weak dependency service feature is enabled or disabled, the effectiveness of the feature can be flexibly adjusted without modifying the application code, thereby decoupling the code logic from the control strategy and improving flexibility.

[0099] Optionally, when configuring at the call chain level, for any call chain, a function for enabling the weak dependency service feature controls whether the weak dependency service feature is enabled for that call chain. After the weak dependency service feature is enabled, its enabled state can be recorded in the thread locale to propagate throughout the call chain. Details regarding the function for enabling the weak dependency service feature can be found in the above embodiments and will not be repeated here.

[0100] In an optional implementation, when controlling whether to enable the weak dependency service feature of the call chain through a function used to enable the weak dependency service feature, the method includes: using the function in the service call management component used to enable the weak dependency service feature as an entry function, the entry function being associated with a list of weak dependency services, and the services in the list of weak dependency services being accessed through the entry function. For details regarding this optional implementation, please refer to the above embodiments, which will not be repeated here.

[0101] The following is an example of configuring the conditions for the weak dependency service feature to take effect in the Spring development framework, but it is not limited to the Spring development framework.

[0102] In this example, the service call management component provides an interface to dynamically control whether weak service dependency features are enabled, and to control whether weak service dependency features are enabled at the service level. It uses "WeakCallableConfigLoader" to read the configuration file and dynamically enable or disable weak service dependency features based on the configuration file. In this example, even if a service has weak service dependency features enabled, it can be disabled dynamically through configuration; that is, weak service dependency features can be dynamically intervened on during runtime.

[0103] In this embodiment, in response to the third configuration operation initiated by the target application through the third extended configuration interface provided by the service call management component, the exception handling strategy corresponding to the target service is dynamically configured.

[0104] The exception handling strategy can be associated with the type of exception. For example, exceptions include timeout exceptions, original logic exceptions, and fast failure exceptions. An exception handling strategy adapted to the type of exception can be used to handle these exceptions. For each type of exception, if an exception is detected, exception information can be output, with different exception information corresponding to different types of exceptions. Furthermore, based on the exception information, the type of exception is identified; and an exception handling strategy adapted to the type of exception is used to handle the exception, allowing the target application to continue running even when the target service call fails.

[0105] In this embodiment, the exception handling strategies include, but are not limited to: timeout exception handling strategy: if the exception type is a timeout exception, terminate the call to the target service and trigger a rollback operation to handle the timeout exception; fast failure exception handling strategy: if the exception type is a fast failure exception, trigger a rollback operation to handle the fast failure exception; original logic exception handling strategy: if the exception type is an original logic exception, trigger a rollback operation to handle the original logic exception.

[0106] In this embodiment, the exception handling strategy can be dynamically configured through the third extended configuration interface, enabling differentiated exception handling strategies. Because the exception handling strategy can be flexibly adjusted, the exception handling service's ability to cope with different application scenarios is improved, effectively ensuring that the target application continues to run when the target service call fails.

[0107] The following is an example of configuring the conditions for the weak dependency service feature to take effect in the Spring development framework, but it is not limited to the Spring development framework.

[0108] The third configuration operation is initiated through the third extended configuration interface provided by the service call management component to dynamically configure the exception handling strategy corresponding to the target service.

[0109] For example, exception handling strategies can be configured at the service level. Taking the target service as an example, if the exception handling strategy for the target service is configured as a fail-fast exception strategy, a "WeakCallableFailFastException" exception will be thrown directly. Based on the exception information, if the exception type is identified as a fail-fast exception, a rollback operation will be triggered to handle the fail-fast exception.

[0110] For example, if the exception handling strategy of the target service is configured as a timeout exception handling strategy, then a "PredictedTimeoutException" exception message will be thrown directly. Based on the exception message, the type of exception will be identified as a timeout exception, then the call to the target service will be terminated and a rollback operation will be triggered to handle the timeout exception.

[0111] For example, if the exception handling strategy of the target service is configured as the original logical exception handling strategy, the exception information corresponding to the original logical exception will be directly thrown. Based on the exception information, the type of the exception will be identified as the original logical exception, and a rollback operation will be triggered to handle the original logical exception.

[0112] In the embodiments of this application, the above embodiments provide a service call exception handling method, the application scenarios of which are diverse and not limited. The technical solutions provided in the embodiments of this application will be described in detail below with reference to specific application scenarios.

[0113] In a cloud service scenario, the cloud services provided by the cloud provider can be output as a cloud service system. This cloud service system can include multiple subsystems, and the multiple subsystems can collaborate across systems through standardized interfaces, enabling a service in one subsystem to call a service in another subsystem to complete a specific function.

[0114] In this scenario, depending on the region, at least some subsystems of the cloud service system can be selectively output. In this example, the cloud service system includes an instance provisioning system and an instance billing system. The instance provisioning system relies on the instance billing system; that is, the instance provisioning system needs to call services (such as billing services) within the instance billing system to achieve on-demand resource production and a closed loop of resource management. In this scenario, core functions of the cloud service system, such as the instance provisioning system, can be selectively output; non-core functions, such as the instance billing system, can be optionally omitted. The distinction between core and non-core functions here is merely illustrative and does not constitute a limitation on this embodiment.

[0115] In cases where an instance provisioning system is provided but an instance billing system is not, resource production on demand and resource management can be achieved through cross-system and service inter-call collaboration.

[0116] In this scenario embodiment, the target application can be implemented as a cloud service system, and the target service can be implemented as an order agent service. This scenario describes the technical solution of this application by taking the example of a service caller (such as an instance provisioning system) initiating a call to the order agent service in the callee (such as an instance billing system). However, it does not mean that the method provided in this application embodiment can only be applied to this application scenario.

[0117] In this scenario embodiment, such as Figures 2-4 The diagram shown is an interactive flowchart of a service call exception handling method provided in this embodiment. Figures 2-4 As shown, the target application includes: service caller 201, entry function 202, order service 203, instance creation service 204, weak dependency service list 205, executor 206, target thread pool 207, order agent service 208, order verification service 209, and timeout detection thread 210.

[0118] In this embodiment, the entry function 202, the list of weakly dependent services 205, the target thread pool 207, the order verification service 209, and the timeout detection thread are all functional components added to the cloud service system by the service call management component. Furthermore, the service caller 201, the order service 203, the instance creation service 204, the executor 206, and the order proxy service 208 are all components inherent to the cloud service system itself.

[0119] Furthermore, such as Figure 2 As shown in step S21, service caller 201 sends a create instance request to entry function 202. Here, the create instance request is an example of a call request. The status is then recorded in the thread log.

[0120] like Figure 2 As shown in S22, the entry function 202 intercepts the instance creation request. The interception method is not limited; for example, it can be implemented based on AOP (Aspect-Oriented Programming).

[0121] In this embodiment, after the cloud service system starts but before issuing an interface call request, steps S23-S26 are executed. During this process, it is possible to determine whether the weak dependency service feature of the call chain is enabled. In this call chain, which is the call chain where the order agent service resides, generally speaking, if the weak dependency service feature of a certain call chain is enabled, it can be assumed that the services on that call chain also have their weak dependency service features enabled. Of course, based on the above description, the effective conditions of the weak dependency service can be dynamically configured according to the first extended configuration interface when the weak dependency service feature of any service is enabled. Steps S23-S26 can be executed sequentially or concurrently; there is no limitation on this. The instance creation request includes the identifier of the order agent service.

[0122] In this embodiment, as Figure 2 As shown in S23, the entry function 202 can determine whether the weak dependency service feature is enabled in the call chain. If the weak dependency service feature is enabled in the call chain, services on the call chain that have enabled the weak dependency service feature can also enable the weak dependency service feature. Figure 2 As shown in S24, the configuration file is checked to determine whether the weak dependency service feature is enabled in the order agent service.

[0123] Furthermore, such as Figure 2 As shown in S25, user information is read, such as a UID, and then the weak dependency service feature is determined based on the UID. Also, as... Figure 2As shown in S26, based on the context information and call parameters of the current call, it is determined whether the weak dependency service feature of the call chain is effective. If the weak dependency service feature of the call chain is effective, the weak dependency service feature of the order agent service can be effective.

[0124] Furthermore, such as Figure 2 As shown in S27, in this embodiment, the weak dependency service feature is recorded as enabled in the thread context. And, as... Figure 2 As shown in S28, the service call management component is introduced into the cloud service system in the form of a resource library. In other words, the service call management component is added to the cloud service system as a functional component.

[0125] In this embodiment, the cloud service system also includes an order service 203, such as... Figure 2 As shown in S29, the order service 203 is used to execute the instance creation logic. Then, as... Figure 2 As shown in S30, the instance creation service 204 performs relevant check logic. For example, it may check whether the resource quota for creating the instance is available; or, it may check whether the service caller or user information that initiated the call request has the corresponding permissions, and so on.

[0126] Furthermore, such as Figure 2 As shown in S31, the instance creation service 204 sends an order verification request. This order verification request is intercepted by the weak dependency service characteristic list 205. The instance creation request involves initiating the order verification request before the instance creation is completed; that is, the instance creation request includes the order verification logic. Furthermore, as... Figure 2 As shown in S32 and S33, the weak dependency service feature list 205 determines whether the order verification request has the weak dependency service feature enabled based on the context information of the current call; and determines the exception handling strategy of the order proxy service.

[0127] In this embodiment, as Figure 3 As shown, receiving Figure 2 The process, such as Figure 3 As shown in S34, the weak dependency service list 205 submits an order verification request to the executor, and as... Figure 3 As shown in S35, executor 206 submits an asynchronous task to execute the order verification request. Furthermore, as... Figure 3 As shown in S36, the order verification request is submitted to the target thread pool 207. Meanwhile, as... Figure 3 As shown in S45, when an order verification request is submitted to the target thread pool 207, the executor 206 submits a timeout detection task to the timeout detection thread 210. This timeout detection task checks whether the call to the order agent service has been completed within its corresponding timeout period. Afterwards, as... Figure 3As shown in S37, it returns the result of an asynchronous call that can be monitored.

[0128] Furthermore, the process of invoking the order agent service is as follows: (e.g.) Figure 3 As shown in S38, the target thread pool 207 allocates idle threads from a specified number of threads for the order verification request, and uses the allocated threads to initiate a call to the order agent service.

[0129] Furthermore, such as Figure 3 As shown in S39, the order agent service 208 checks whether the order verification request can be executed. And, as... Figure 3 As shown in S40, the order agent service 208 initiates a call to the order verification service 209 to create the order verification logic. Further, as... Figure 3 As shown in S41, the order verification service 209 executes the order verification logic. The response time of the order verification service may exceed the timeout period corresponding to the call to the order agent service.

[0130] Furthermore, such as Figure 3 As shown in S42-S43, the order verification service 209 returns the verification result of the order verification service to the order agent service 208; and the order agent service 208 returns the verification result of the order verification service to the target thread pool 207. When the target thread pool 207 receives the verification result of the order verification service, as follows... Figure 3 As shown in S44, the asynchronous call is marked as complete, and the result of the asynchronous call is set.

[0131] If a timeout exception is detected, then as follows: Figure 3 As shown in S46, the timeout detection thread 210 creates the task after a timeout exception occurs; and as... Figure 3 As shown in S47, the exception call result corresponding to the timeout exception is returned to executor 206. Upon receiving the exception call result corresponding to the timeout exception, executor 206, as shown in the S47 code, performs the following actions: Figure 3 As shown in S48, the exception call result corresponding to the timeout exception is returned to the weak dependency service feature list 205.

[0132] Furthermore, if the weak dependency service feature list 205 receives an exception call result corresponding to a timeout exception, such as... Figure 3 As shown in S50, after a timeout exception occurs during scheduling, as shown in S51, it checks whether the asynchronous call has completed. If it has not completed, it sets a rendering timeout result. Then, as shown in S52, it sets the asynchronous call result.

[0133] In this embodiment, as Figure 4 As shown, receiving Figure 3 The process, in Figure 4 In this context, the returned results of asynchronous calls can include various types. For example... Figure 4 As shown in S53, it could return a normal result. For example, it could be as follows: Figure 4 As shown in S54, the rendering timeout result is returned. For example, it could be as follows: Figure 4 As shown in S55, the returned result is "null". For example, it could also be as follows: Figure 4 As shown in S56, it returns a specified exception, such as a fast failure exception. For example, it could also be as follows: Figure 4 As shown in S57, it returns the specified result. For example, it could also be as follows: Figure 4 As shown in S58, an abnormal pass-through is thrown.

[0134] Furthermore, such as Figure 4 As shown in S59→S60→S61→S62, the result return path includes: Instance Creation Service 204→Order Service 203→Entry Function 202→Service Caller 201.

[0135] Figure 5 This is a flowchart illustrating a component injection method provided for an exemplary embodiment of this application. Figure 5 As shown, the method includes:

[0136] S501: Implement the exception handling logic in the service call process in a componentized manner to obtain the service call management component;

[0137] S502: Introduce the service invocation management component into the target application in the form of a resource library;

[0138] S502: Configure the service call management component to act as a functional component in the target application, and provide exception handling services during the service call process for the target application.

[0139] In this embodiment, the service call exception handling method provided in the above embodiments is used to provide exception handling services during the service call process for the target application.

[0140] In an optional embodiment, when configuring the service invocation management component to act as a functional component in the target application and provide exception handling services during the service invocation process for the target application, the method includes: adding a component identifier to the service invocation management component using annotations, and instructing the target application to add the service invocation management component as a functional component based on the component identifier; and enabling weak dependency service features for at least one service that the target application can invoke in the service invocation management component, so that the service invocation management component can provide exception handling services during the service invocation process for the target application.

[0141] In an optional embodiment, when enabling the weak dependency service feature for at least one service that the target application can call in the service call management component, the process includes: using a function in the service call management component for enabling the weak dependency service feature as an entry function, the entry function being associated with a weak dependency service list, and the services in the weak dependency service list being accessed through the entry function; and adding the identifier of at least one service that the target application can call to the weak dependency service list to enable the weak dependency service feature for the at least one service.

[0142] The detailed implementation methods and beneficial effects of each step in this embodiment have been described in detail in the foregoing embodiments, and will not be elaborated here.

[0143] It should be noted that the execution subject of each step of the method provided in the above embodiments can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 101 to 103 can be device A; or the execution subject of steps 101 and 102 can be device A, and the execution subject of step 103 can be device B; and so on.

[0144] Furthermore, some processes described in the above embodiments and accompanying drawings include multiple operations appearing in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.

[0145] Figure 6 This is a schematic diagram of the structure of an electronic device provided as another exemplary embodiment of this application. For example... Figure 6 As shown, the electronic device includes a memory 64 and a processor 65.

[0146] Memory 64 is used to store computer programs and can be configured to store various other data to support operation on the electronic device. Examples of this data include instructions for any application or method used to operate on the electronic device, data structures, contact data, phone book data, messages, pictures, videos, etc.

[0147] Processor 65, coupled to memory 64, is used to execute computer programs in memory 64 for: intercepting call requests initiated by the target application to a target service during its operation, and initiating a call to the target service on behalf of the target application, wherein the target service is any service that the target application can call; if the target service has a weak dependency service feature enabled, and an abnormal situation is detected in the call process of the target service, then the abnormal situation is handled according to the abnormal handling strategy corresponding to the target service, and an abnormal handling response message is returned to the target application so that the target application can continue to run when the target service call is abnormal; wherein, the weak dependency service feature is a service feature that does not affect the continued operation of the service caller when the service call is abnormal.

[0148] In an optional embodiment, the processor 65 is further configured to: output exception information when an exception is detected in the call process of the target service, wherein different types of exceptions correspond to different exception information;

[0149] Accordingly, when the processor 65 processes the abnormal situation according to the abnormal handling strategy corresponding to the target service, it is configured to: identify the type of the abnormal situation based on the abnormal information; and process the abnormal situation by adopting an abnormal handling strategy adapted to the type of the abnormal situation.

[0150] In an optional embodiment, when the processor 65 processes the abnormal situation using an exception handling strategy adapted to the type of the abnormal situation, it specifically performs the following: if the type of the abnormal situation is a timeout abnormal situation, terminate the call to the target service and trigger a rollback operation to process the timeout abnormal situation; if the type of the abnormal situation is a primary logic abnormal situation, trigger a rollback operation to process the primary logic abnormal situation; if the type of the abnormal situation is a fast failure abnormal situation, trigger a rollback operation to process the fast failure abnormal situation.

[0151] In an optional embodiment, when the processor 65 intercepts the call request initiated by the target application to the target service during its operation and initiates the call to the target service on behalf of the target application, it is specifically configured to: intercept the call request initiated by the target application to the target service during its operation, submit the call request to a target thread pool, the target thread pool including a specified number of threads; allocate an idle thread for the call request from the specified number of threads, and use the allocated thread to initiate the call to the target service.

[0152] In an optional embodiment, before submitting the call request to the target thread pool, the processor 65 is further configured to: use the default thread pool in the service call management component as the target thread pool; or, in response to a thread pool configuration operation initiated by the target application through the thread pool configuration interface provided by the service call management component, use the thread pool configured by the target application as the target thread pool.

[0153] In an optional embodiment, the processor 65 is further configured to: when a call is initiated to the target service, create a timeout detection task, the timeout detection task being configured to detect whether the call to the target service is completed within the timeout period corresponding to the target service; if the call to the target service is detected not to be completed within the timeout period, determine that a timeout exception has occurred in the call process of the target service.

[0154] In an optional embodiment, the processor 65 is further configured to: introduce the service call management component into the target application in the form of a resource library, and configure the service call management component to act as a functional component in the target application to provide exception handling services during the service call process for the target application.

[0155] In an optional embodiment, when the processor 65 configures the service call management component to act as a functional component in the target application and provide exception handling services during the service call process for the target application, it specifically performs the following: adding a component identifier to the service call management component using annotations, and instructing the target application to add the service call management component as a functional component based on the component identifier; and enabling weak dependency service features for at least one service that the target application can call in the service call management component, so that the service call management component can provide exception handling services during the service call process for the target application.

[0156] In an optional embodiment, when the processor 65 enables the weak dependency service feature for at least one service that the target application can call in the service call management component, it is specifically configured to: use the function in the service call management component used to enable the weak dependency service feature as an entry function, the entry function being associated with a weak dependency service list, and the services in the weak dependency service list being accessed through the entry function; add the identifier of at least one service that the target application can call to the weak dependency service list, thereby enabling the weak dependency service feature for the at least one service.

[0157] In an optional embodiment, when the processor 65 intercepts a call request initiated by the target application to the target service during runtime, it is specifically configured to: receive an access request initiated by the target application to the entry function during runtime, the access request including the identifier of the target service; determine the call request initiated by the target application to the target service based on the identifier of the target service; the entry function is a function in the service call management component used to enable the weak dependency service feature, the entry function is associated with a weak dependency service list, and the services in the weak dependency service list are accessed through the entry function.

[0158] In an optional embodiment, the processor 65 is further configured to perform at least one of the following operations: in response to a first configuration operation initiated by the target application through a first extended configuration interface provided by the service call management component, when the weak dependency service feature of the target service is enabled, dynamically configure the activation conditions of the weak dependency service feature of the target service based on the context information of the current call, the call parameters, and / or user information; in response to a second configuration operation initiated by the target application through a second extended configuration interface provided by the service call management component, disable or enable the weak dependency service feature of the target service as needed; in response to a third configuration operation initiated by the target application through a third extended configuration interface provided by the service call management component, dynamically configure the exception handling strategy corresponding to the target service.

[0159] Furthermore, such as Figure 6 As shown, the electronic device also includes other components such as a communication component 66, a display 67, a power supply component 68, and an audio component 69. Figure 6 The diagram only shows some components and does not mean that the electronic device includes only these components. Figure 6 The components shown. Additionally... Figure 6 The components within the dashed box are optional, not mandatory, and their specific requirements depend on the product form of the work node. The electronic device in this embodiment can be a terminal device such as a desktop computer, laptop computer, smartphone, or IoT device, or a server-side device such as a conventional server, cloud server, or server array. If the electronic device in this embodiment is a terminal device such as a desktop computer, laptop computer, or smartphone, it may include... Figure 6 The components within the dashed box in the figure; if the electronic device in this embodiment is implemented as a server-side device such as a conventional server, cloud server or server array, the components within the dashed box in the figure may not be included.

[0160] The aforementioned memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0161] The aforementioned communication component is configured to facilitate wired or wireless communication between the device containing the communication component and other devices. The device containing the communication component can access wireless networks based on communication standards, such as 2G, 3G, 4G / LTE, 5G, or combinations thereof. In one exemplary embodiment, the communication component receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel.

[0162] The aforementioned display includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen can be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation.

[0163] The aforementioned power supply components provide power to various components within the device in which they reside. These power supply components may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to the device in which they reside.

[0164] The aforementioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC) configured to receive external audio signals when the device containing the audio component is in an operating mode, such as call mode, recording mode, or voice recognition mode. The received audio signals can be further stored in memory or transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.

[0165] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to implement the steps in the above-described method embodiments. The computer-readable storage medium includes volatile or non-volatile components, or a combination thereof, and can be removable or non-removable. Examples of computer-readable storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random-access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), flash memory or other memory technologies, CD-ROM, Digital Video Disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium.

[0166] Accordingly, this application also provides a computer program product, which includes a computer program or instructions that, when executed by a processor, cause the processor to implement the steps in the above method embodiments. It should be understood that each step or combination of steps in the above method flow can be implemented by the computer program or instructions. Furthermore, these computer programs or instructions can be applied to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device, enabling the processor of the general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to function as an apparatus for implementing the corresponding functions in the above method embodiments.

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

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

Claims

1. A service call exception handling method characterized by, A service invocation management component applied to a target application, wherein the service invocation management component is obtained by modularizing the exception handling logic during the service invocation process, the method includes: Intercept the call request initiated by the target application to the target service during the running process, and initiate the call to the target service on behalf of the target application. The target service is any service that the target application can call. If the target service has weak dependency features enabled, and an exception is detected during the call process of the target service, the exception is handled according to the exception handling policy corresponding to the target service, and an exception handling response message is returned to the target application so that the target application can continue to run when the target service call fails. The weak dependency service characteristic is a service characteristic where service call exceptions do not affect the continued operation of the service caller.

2. The method according to claim 1, characterized in that, Also includes: If an abnormal situation occurs during the call process of the target service, an abnormal information is output, wherein different types of abnormal situations correspond to different abnormal information; Accordingly, the abnormal situation is handled according to the abnormal handling strategy corresponding to the target service, including: identifying the type of the abnormal situation based on the abnormal information; and handling the abnormal situation by adopting an abnormal handling strategy adapted to the type of the abnormal situation.

3. The method according to claim 2, characterized in that, An exception handling strategy adapted to the type of the exception is adopted to handle the exception, including: If the type of the abnormal situation is a timeout abnormal situation, terminate the call to the target service and trigger a rollback operation to handle the timeout abnormal situation; If the type of the abnormal situation is a primitive logical abnormal situation, a rollback operation is triggered to handle the primitive logical abnormal situation; If the type of the abnormal situation is a fast failure exception, a rollback operation is triggered to handle the fast failure exception.

4. The method according to claim 1, characterized in that, Intercepting the call requests initiated by the target application to the target service during runtime, and initiating the call to the target service on behalf of the target application, including: Intercept the call request initiated by the target application to the target service during the running process, and submit the call request to the target thread pool, the target thread pool including a specified number of threads; An idle thread is allocated from the specified number of threads for the call request, and the allocated thread is used to initiate a call to the target service.

5. The method according to claim 4, characterized in that, Before submitting the call request to the target thread pool, the following is also included: Use the default thread pool in the service call management component as the target thread pool; or In response to the thread pool configuration operation initiated by the target application through the thread pool configuration interface provided by the service call management component, the thread pool configured by the target application is used as the target thread pool.

6. The method according to claim 1, characterized in that, Also includes: When a call is made to the target service, a timeout detection task is created. The timeout detection task is used to detect whether the call to the target service is completed within the timeout period corresponding to the target service. If it is detected that the call to the target service is not completed within the timeout period, it is determined that a timeout exception has occurred in the call process to the target service.

7. The method according to any one of claims 1-6, characterized in that, Also includes: The service call management component is introduced into the target application as a resource library, and the service call management component is configured to act as a functional component in the target application to provide exception handling services during the service call process.

8. The method according to claim 7, characterized in that, Configure the service invocation management component to act as a functional component in the target application, providing exception handling services during the service invocation process for the target application, including: The service invocation management component is annotated with a component identifier, and the target application is instructed to add the service invocation management component as a functional component based on the component identifier; and In the service invocation management component, a weak dependency service feature is enabled for at least one service that the target application can invoke, so that the service invocation management component can provide the target application with exception handling services during the service invocation process.

9. The method according to claim 8, characterized in that, In the service invocation management component, the weak dependency service feature is enabled for at least one service that the target application can invoke, including: The function in the service call management component used to enable the weak dependency service feature is used as the entry function. The entry function is associated with the weak dependency service list, and the services in the weak dependency service list are accessed through the entry function. Add the identifier of at least one service that the target application can call to the weak dependency service list to enable the weak dependency service feature for the at least one service.

10. The method according to any one of claims 1-6 and 8-10, characterized in that, Intercepting the call requests initiated by the target application to the target service during its runtime, including: Receive an access request initiated by the target application to the entry function during its operation, the access request including the identifier of the target service; determine the call request initiated by the target application to the target service based on the identifier of the target service; The entry function is a function in the service call management component used to enable the weak dependency service feature. The entry function is associated with a list of weak dependency services, and the services in the weak dependency service list are accessed through the entry function.

11. The method according to any one of claims 1-6 and 8-10, characterized in that, It also includes at least one of the following operations: In response to the first configuration operation initiated by the target application through the first extended configuration interface provided by the service call management component, when the target service enables the weak dependency service feature, the effective conditions of the weak dependency service feature of the target service are dynamically configured according to the context information of the current call, the call parameters and / or user information. In response to the second configuration operation initiated by the target application through the second extended configuration interface provided by the service call management component, the weak dependency service feature of the target service is turned off or on as needed. In response to the third configuration operation initiated by the target application through the third extended configuration interface provided by the service call management component, the exception handling strategy corresponding to the target service is dynamically configured.

12. A component injection method, characterized in that, include: The exception handling logic during the service call process is implemented in a component-based manner to obtain the service call management component; The service call management component is introduced into the target application as a resource library; Configure the service call management component to act as a functional component in the target application, and provide exception handling services during the service call process for the target application.

13. The method according to claim 12, characterized in that, Configure the service invocation management component to act as a functional component in the target application, providing exception handling services during the service invocation process for the target application, including: The service invocation management component is annotated with a component identifier, and the target application is instructed to add the service invocation management component as a functional component based on the component identifier; and In the service invocation management component, a weak dependency service feature is enabled for at least one service that the target application can invoke, so that the service invocation management component can provide the target application with exception handling services during the service invocation process.

14. The method according to claim 12 or 13, characterized in that, In the service invocation management component, the weak dependency service feature is enabled for at least one service that the target application can invoke, including: The function in the service call management component used to enable the weak dependency service feature is used as the entry function. The entry function is associated with the weak dependency service list, and the services in the weak dependency service list are accessed through the entry function. Add the identifier of at least one service that the target application can call to the weak dependency service list to enable the weak dependency service feature for the at least one service.

15. An electronic device, characterized in that, include: A memory and a processor, the memory for storing a computer program, the processor coupled to the memory for executing the computer program to implement the steps of the method according to any one of claims 1-11 and 12-14.

16. A computer-readable storage medium storing a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, the processor is enabled to perform the steps of the method according to any one of claims 1-11 and 12-14.

17. A computer program product, characterized in that, include: A computer program / instruction that, when executed by a processor, causes the processor to perform the steps of the method according to any one of claims 1-11 and 12-14.