Lifting interface fault tolerance method applied to urban operation center platform
By using aspect-oriented programming to intercept exceptions in API calls and retrieving prepared results from the cache, the problems of fragmentation and complexity in API call exception handling are solved, achieving efficient fault tolerance and optimizing user experience, thereby improving system stability and security.
Patent Information
- Application Number
- CN202411299524.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-01-07
AI Technical Summary
In existing technologies, exception handling for API calls is scattered and inconsistent, which affects user experience, fails to effectively utilize cached data, is difficult to handle complex exception scenarios, and poses security risks.
By intercepting API calls using Aspect-Oriented Programming (AOP), exceptions are captured and prepared results are retrieved from the cache. Redis or Guava is used to cache and return prepared results when API exceptions occur. The cached content is updated periodically to ensure validity.
Improve system fault tolerance and stability, optimize user experience, enhance cache utilization efficiency, reduce maintenance costs, and improve system reliability and security.
Smart Images

Figure CN119271442A_ABST
Abstract
Description
Technical Field
[0001] The invention discloses a method for improving interface fault tolerance applied to a city operation central platform, and relates to the technical field of computer Java back-end development. Background Art
[0002] With the rapid development of information technology, the complexity and scale of modern software systems are increasing. Especially in the context of the widespread application of cloud computing, big data and microservice architecture, the reliability and stability of the system have become key factors. For large-scale distributed systems, various services in the system call each other through interfaces, and the stability of these interfaces directly affects the overall performance of the system and user experience. However, due to various uncontrollable factors such as network fluctuations, insufficient resources, and abnormal third-party services, exceptions may occur in interface calls, resulting in unavailability of system services and even cascading failures.
[0003] In the existing technology, the handling of interface call exceptions usually relies on developers to manually add exception handling logic in the code, such as catching exceptions and returning error information. This method has the following shortcomings:
[0004] Exception handling is scattered and not unified: Manually handling exceptions in each interface leads to scattered exception handling logic and lack of unified management, which increases code complexity and maintenance costs.
[0005] Poor user experience: When an exception occurs in an interface, the traditional processing method is usually to return an error code or exception information, which is directly exposed to the user. This not only affects the user experience, but may also leak internal system information, posing a security risk.
[0006] Inability to effectively utilize cache: Even in abnormal situations, there may be cache data related to the current interface in the system. However, traditional exception handling methods cannot utilize this cache data, resulting in service interruption when the interface is abnormal.
[0007] Difficult to deal with complex exception scenarios: In a distributed system, the causes of exceptions may be varied. A single exception handling method is difficult to deal with complex exception scenarios, such as network delays, unavailability of some services, etc. Summary of the invention
[0008] In view of the problems of the prior art, the present invention provides a method for improving interface fault tolerance applied to a city operation central platform, which improves system stability and user experience by automatically capturing exceptions in interface calls and obtaining preliminary results from a cache based on the interface name.
[0009] The specific scheme proposed by the present invention is:
[0010] The present invention provides an interface fault tolerance enhancement method applied to a city operation central platform, comprising:
[0011] Step 1: Use the aspect-oriented programming method AOP to define the interface or method that needs to be intercepted using the pointcut expression, and intercept the call of the interface in the central platform system according to the interface that needs to be intercepted.
[0012] Step 2: During the interface call process, capture any exceptions thrown. When an exception is captured, record the exception log for subsequent analysis.
[0013] Step 3: According to the name of the interface that captures the exception, match the pre-cached preliminary results in the cache.
[0014] Step 4: Return the query results to the user of the central platform system.
[0015] Furthermore, in step 3 of the method for improving interface fault tolerance applied to the city operation central platform, Redis or Guava is used to cache the preparation results of each interface, so as to return the preparation results to the user when an exception occurs during the interface call process.
[0016] Furthermore, in step 3 of the method for improving interface fault tolerance applied to the city operation central platform, the pre-cached preparation results are queried in the cache, including: querying the pre-cached preparation results in the cache according to the interface name of the captured exception, and if the corresponding preparation results exist in the cache, the preparation results are directly returned; if there are no matching preparation results in the cache, a general backup response is returned to inform the central platform system user that it is temporarily unavailable.
[0017] Furthermore, the method for improving interface fault tolerance applied to the city operation central platform also includes step 5, in which cache update is performed: using a scheduled task to update the cache content regularly or according to conditions to ensure the validity and timeliness of the cache results.
[0018] The present invention also provides a fault-tolerant device for an interface for an urban operation central platform, comprising an interception module, an abnormality management module, a query module and a return output module.
[0019] The interception module uses the aspect-oriented programming method AOP to define the interface or method that needs to be intercepted using the pointcut expression, and intercepts the call of the interface in the central platform system according to the interface that needs to be intercepted.
[0020] The exception management module captures any exceptions thrown during the interface call process, and records the exception log for subsequent analysis when an exception is captured.
[0021] The query module matches the pre-cached preliminary results in the cache according to the interface name of the captured exception.
[0022] The return output module returns the query results to the users of the central platform system.
[0023] Furthermore, the query module of the interface fault tolerance enhancement device applied to the city operation central platform uses Redis or Guava to cache the preparation results of each interface, and is used to return the preparation results to the user when an exception occurs during the interface call process.
[0024] Furthermore, the query module of the interface fault tolerance device applied to the city operation central platform queries the pre-cached preparation results in the cache, including: querying the pre-cached preparation results according to the interface name of the captured exception, if the corresponding preparation results exist in the cache, the preparation results are directly returned, if there is no matching preparation result in the cache, a general backup response is returned to inform the central platform system user that it is temporarily unavailable.
[0025] Furthermore, the device for improving interface fault tolerance applied to the city operation central platform also includes a cache update module, which performs cache updates: using scheduled tasks to update cache contents regularly or according to conditions to ensure the validity and timeliness of cache results.
[0026] The benefits of the present invention are:
[0027] (1) Improve the fault tolerance of the central platform system: intercept exceptions in interface calls and return cached results through aspect technology, ensuring that effective responses can still be provided when the interface fails, thereby greatly improving the fault tolerance and stability of the system.
[0028] (2) Optimize user experience: Avoid exposing interface anomalies directly to users, reduce user dissatisfaction caused by system failures, and improve user satisfaction and trust in the system.
[0029] (3) Enhance cache utilization efficiency: By using the prepared results in the cache, requests can be responded to quickly when the interface is abnormal, reducing system resource consumption and response time, thereby improving overall system performance.
[0030] (4) Reduce system maintenance costs: Through a unified exception handling mechanism, the need for personalized exception handling for a single interface is reduced, thereby simplifying system maintenance and upgrades and reducing operating costs.
[0031] (5) Improve system reliability and availability: Through effective fault-tolerant measures and caching mechanisms, the system can maintain high availability even under abnormal circumstances, ensuring service continuity and reliability.
[0032] (6) Enhanced security and privacy protection: Prevent abnormal information from being directly exposed to users, avoid leakage of sensitive information, and improve the security and privacy protection level of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION
[0034] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0035] Example 1
[0036] The present invention provides an interface fault tolerance enhancement method applied to a city operation central platform, comprising:
[0037] Step 1: Use the aspect-oriented programming method AOP to define the interface or method that needs to be intercepted using the pointcut expression, and intercept the call of the interface in the central platform system according to the interface that needs to be intercepted.
[0038] Step 2: During the interface call process, capture any exceptions thrown. When an exception is captured, record the exception log for subsequent analysis.
[0039] Step 3: According to the name of the interface that captured the exception, query the pre-cached preparation results in the cache.
[0040] You can use Redis or Guava to cache the prepared results of each interface and return the prepared results to the user when an exception occurs during the interface call.
[0041] In step 3, querying the pre-cached preparation results in the cache may include: querying the pre-cached preparation results according to the interface name that captured the exception. If the corresponding preparation results exist in the cache, the preparation results are directly returned as the query results. If there are no matching preparation results in the cache, a general backup response is returned as the query result to inform the central platform system user that it is temporarily unavailable.
[0042] Step 4: Return the query results to the user of the central platform system.
[0043] Step 5: Update the cache: Use scheduled tasks to update the cache content regularly or according to conditions to ensure the validity and timeliness of the cache results.
[0044] Example 2
[0045] The present invention also provides a fault-tolerant device for an interface for an urban operation central platform, comprising an interception module, an abnormality management module, a query module and a return output module.
[0046] The interception module uses the aspect-oriented programming method AOP to define the interface or method that needs to be intercepted using the pointcut expression, and intercepts the call of the interface in the central platform system according to the interface that needs to be intercepted.
[0047] The exception management module captures any exceptions thrown during the interface call process, and records the exception log for subsequent analysis when an exception is captured.
[0048] The query module searches the cache for pre-cached results based on the name of the interface that captured the exception.
[0049] The return output module returns the obtained preparation results to the users of the central platform system.
[0050] As the information interaction and execution process between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention, the specific contents can be found in the description of the embodiment of the method of the present invention and will not be repeated here.
[0051] Likewise, the benefits of the device of the present invention are:
[0052] (1) Improve the fault tolerance of the central platform system: intercept exceptions in interface calls and return cached results through aspect technology, ensuring that effective responses can still be provided when the interface fails, thereby greatly improving the fault tolerance and stability of the system.
[0053] (2) Optimize user experience: Avoid exposing interface anomalies directly to users, reduce user dissatisfaction caused by system failures, and improve user satisfaction and trust in the system.
[0054] (3) Enhance cache utilization efficiency: By using the prepared results in the cache, requests can be responded to quickly when the interface is abnormal, reducing system resource consumption and response time, thereby improving overall system performance.
[0055] (4) Reduce system maintenance costs: Through a unified exception handling mechanism, the need for personalized exception handling for a single interface is reduced, thereby simplifying system maintenance and upgrades and reducing operating costs.
[0056] (5) Improve system reliability and availability: Through effective fault-tolerant measures and caching mechanisms, the system can maintain high availability even under abnormal circumstances, ensuring service continuity and reliability.
[0057] (6) Enhanced security and privacy protection: Prevent abnormal information from being directly exposed to users, avoid leakage of sensitive information, and improve the security and privacy protection level of the system.
[0058] It should be noted that not all steps and modules in the above-mentioned processes and device structures are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.
[0059] The above-described embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or changes made by those skilled in the art based on the present invention are within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.
Claims
1. A fault-tolerant method for improving interfaces applied to a city operation central platform, characterized in that include: Step 1: Use the aspect-oriented programming method AOP to define the interface or method that needs to be intercepted using the pointcut expression, and intercept the call of the interface in the central platform system according to the interface that needs to be intercepted. Step 2: During the interface call process, capture any exceptions thrown. When an exception is captured, record the exception log for subsequent analysis. Step 3: According to the name of the interface that captures the exception, match the pre-cached preliminary results in the cache. Step 4: Return the query results to the user of the central platform system.
2. According to claim 1, a fault-tolerant method for improving interface applied to a city operation central platform is characterized by: In step 3, Redis or Guava is used to cache the preparation results of each interface, so as to return the preparation results to the user when an exception occurs during the interface call process.
3. According to claim 1, a fault-tolerant method for improving interface applied to a city operation central platform is characterized in that In step 3, the pre-cached preparation results are queried in the cache, including: querying the pre-cached preparation results according to the interface name that captures the exception. If the corresponding preparation results exist in the cache, the preparation results are returned directly. If there is no matching preparation result in the cache, a general backup response is returned to inform the central platform system user that it is temporarily unavailable.
4. According to claim 1, a fault-tolerant method for improving interface applied to a city operation central platform is characterized by: The step 5 is also included. In the step 5, the cache is updated: a scheduled task is used to update the cache content regularly or according to conditions to ensure the validity and timeliness of the cache result.
5. A lifting interface fault-tolerant device applied to a city operation central platform, characterized in that Including interception module, exception management module, query module and return output module, The interception module uses the aspect-oriented programming method AOP to define the interface or method that needs to be intercepted using the pointcut expression, and intercepts the call of the interface in the central platform system according to the interface that needs to be intercepted. The exception management module captures any exceptions thrown during the interface call process, and records the exception log for subsequent analysis when an exception is captured. The query module matches the pre-cached preliminary results in the cache according to the interface name of the captured exception. The return output module returns the query results to the users of the central platform system.
6. The lifting interface fault-tolerant device applied to the urban operation central platform according to claim 5 is characterized in that The query module uses Redis or Guava to cache the prepared results of each interface, and returns the prepared results to the user when an exception occurs during the interface call process.
7. The lifting interface fault-tolerant device applied to the urban operation central platform according to claim 5 is characterized in that The query module queries the pre-cached prepared results in the cache, including: querying the pre-cached prepared results according to the interface name that captures the exception. If the corresponding prepared results exist in the cache, the prepared results are returned directly. If there are no matching prepared results in the cache, a general backup response is returned to inform the central platform system user that it is temporarily unavailable.
8. The method for improving interface fault tolerance applied to the city operation central platform according to claim 5 is characterized by: It also includes a cache update module, which performs cache updates: using scheduled tasks to update cache content regularly or according to conditions to ensure the validity and timeliness of cache results.