Remote procedure calling method based on Zookeeper distributed configuration center

Through the distributed configuration center based on Zookeeper, combined with interface programming, AOP sections and national encryption, the service discovery, load balancing and data security problems of the traditional RPC framework in the distributed system are solved, and efficient and secure remote process calls are achieved.

CN120499248APending Publication Date: 2025-08-15FUJIAN FUJITSU COMM SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510532120.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

Traditional RPC frameworks face challenges in distributed systems such as service discovery, load balancing, data security and system observability, especially in highly concurrency and complex network environments, which are difficult to achieve transparent calls, efficient management and secure transmission.

Method used

The remote procedure call method based on the Zookeeper distributed configuration center is adopted, and dynamic address management and load balancing are achieved through interface programming, AOP section interception and national encryption, combined with Zookeeper service discovery, and the full link tracking is transmitted through the trace_id in HTTP requests, and the exception handling is customized.

Benefits of technology

It simplifies the development process of inter-service calls, ensures data security and transmission integrity, improves the observability and availability of the system, and supports efficient load balancing and fault location.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120499248A_ABST
    Figure CN120499248A_ABST
Patent Text Reader

Abstract

The invention discloses a remote procedure calling method based on a Zookeeper distributed configuration center, and the method comprises the steps: obtaining an interface calling request between different micro-services by the configuration center, hiding the details of the interface calling request through interface type programming, and adding an annotation label in the interface calling request; acquiring request parameters through reflection and serializing the request parameters into json according to a method for intercepting corresponding annotation identifiers through an AOP section; encrypting json by using national secret, intercepting and extracting address information by a configuration center through an AOP aspect to obtain a complete request address, and initiating an http request to a target micro-service; and the configuration center obtains a response message returned by the target micro-service, performs state encryption decryption on the response message, deserializes the entity class of the java, and forwards the response message to the micro-service initiating the request in combination with a return value reflected and injected into the interface. The user-defined exception mechanism enables error processing to be more concentrated and efficient, and maintenance and debugging are convenient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of microservice calling technology, and in particular to a remote procedure calling method based on a Zookeeper distributed configuration center. Background Art

[0002] With the widespread adoption of distributed systems and microservices architectures in modern enterprises, remote procedure calls (RPCs), as an efficient cross-process communication technology, have become a key cornerstone for building high-performance, scalable systems. However, traditional RPC frameworks often struggle to meet the demands of dynamic service management, load balancing, data security, and system observability. This is especially true in highly concurrent and complex network environments. Enabling transparent service invocation, efficient management, and secure transmission has become a pressing technical challenge. Summary of the Invention

[0003] The purpose of this invention is to solve the many challenges faced by traditional RPC frameworks in distributed systems, especially in service discovery, load balancing, data security, and system observability. It provides a remote procedure call method based on the Zookeeper distributed configuration center, and provides a safe, efficient, easy-to-use and highly scalable RPC solution to meet the diverse needs of modern distributed systems.

[0004] The technical solution adopted in the present invention is: The remote procedure call method based on the Zookeeper distributed configuration center includes the following steps: Step 1: The configuration center obtains the interface call requests between different microservices, hides the details of the interface call requests through interface programming, and adds annotations to the interface call requests; Step 2: intercept the method marked with the corresponding annotation through the AOP aspect, obtain the request parameters through reflection and serialize them into JSON; Step 3, use the national encryption to encrypt json, Step 4: The configuration center intercepts and extracts the address information through the AOP aspect to obtain the complete request address and initiates an HTTP request to the target microservice; In step 5, the configuration center obtains the response message returned by the target microservice, decrypts the response message with national encryption, deserializes the Java entity class, injects the return value into the interface through reflection, and forwards it to the microservice that initiated the request.

[0005] Furthermore, in step 1, the configuration center obtains interface call requests between different microservices through the control layer.

[0006] Furthermore, after the Chinese secret is encrypted in step 3, the current user information access_token field and trace_id link ID field are transparently transmitted in the http request header.

[0007] Furthermore, in step 4, the configuration center obtains the relative URL address of the interface method and the target microservice instance address and concatenates them to form a complete request address.

[0008] Furthermore, step 5 specifically includes the following steps: Step 5-1: Get the response message returned by the target microservice; Step 5-2: Determine whether the target microservice responds normally based on the HTTP CODE of the response message; if so, execute step 5-3; otherwise, prompt a response exception; In step 5-3, the response message is decrypted using the national secret code and deserialized into a Java entity class. The return value of the interface is injected into the interface through reflection and forwarded to the microservice that initiated the request.

[0009] This invention utilizes the above technical solutions and offers the following advantages over existing technologies: 1) Annotation-driven interface programming: By adding the @FeignMapping annotation to interface methods, the development process for inter-service calls is simplified, hiding the complex details of HTTP requests. 2) Aspect-oriented programming (AOP) and reflection technology: Utilizing AOP to intercept annotation methods, request parameters are obtained through reflection, and JSON serialization and national security encryption are performed to ensure data security. 3) Service discovery and dynamic address splicing: Integrating the Zookeeper service discovery mechanism, dynamically obtains the addresses of microservice instances, enabling load balancing and failover.

[0010] This invention transmits the trace_id in the HTTP header to achieve full-link request tracking, facilitating monitoring and troubleshooting. It integrates national encryption algorithms into requests and responses to ensure data transmission security and comply with national security standards. It also handles HTTP response exceptions through a custom RpcException, improving system robustness and maintainability. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments; Figure 1 The figure is a flow chart of the remote procedure call method based on the Zookeeper distributed configuration center of the present invention. DETAILED DESCRIPTION

[0012] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0013] Definition: RPC (Remote Procedure Call) is a protocol and technology that allows programs to call services or methods on remote computers. With RPC, developers can call remote services just like calling local services, without having to worry about the underlying network communication details. It is widely used in distributed systems to enable communication and collaboration between different services or modules.

[0014] Zookeeper is an open-source distributed coordination service used to manage configuration, naming, service discovery, and load balancing in distributed systems. It maintains a hierarchical data structure (called a ZNode) to provide consistency services, fault detection, and recovery for distributed applications. In this patent, it is primarily used for the dynamic registration and discovery of service instances.

[0015] The National Cryptography Algorithm (NSA) is a set of cryptographic algorithm standards developed by the China National Cryptography Administration. These include SM2 (asymmetric encryption algorithm), SM3 (hash algorithm), and SM4 (symmetric encryption algorithm). These algorithms are widely used in China's information security sector to ensure the confidentiality, integrity, and authenticity of data transmission and storage.

[0016] Microservices is a software architectural style that decomposes an application into a series of small, independent services, each focusing on a single business function and interacting through lightweight communication mechanisms such as HTTP or message queues. This architecture improves the system's autonomy, scalability, and development efficiency.

[0017] Load balancing is a technology that distributes network traffic or computing tasks across multiple servers or resources. It aims to optimize resource utilization, improve throughput, reduce latency, and ensure high system availability. In this patent, load balancing achieves efficient RPC calls by dynamically selecting service instances.

[0018] like Figure 1 As shown, the present invention discloses a remote procedure call method based on Zookeeper distributed configuration center, which includes the following steps: Step 1: The configuration center obtains the interface call requests between different microservices, hides the details of the interface call requests through interface programming, and adds annotations to the interface call requests; Furthermore, in step 1, the configuration center obtains interface call requests between different microservices through the control layer.

[0019] Step 2: intercept the method marked with the corresponding annotation through the AOP aspect, obtain the request parameters through reflection and serialize them into JSON; Step 3: Encrypt the JSON using the national encryption algorithm and transparently transmit the current user information (access_token field) and trace_id link ID field in the HTTP request header. Step 4: The configuration center obtains the relative URL address of the interface method and the target microservice instance address, concatenates them into a complete request address, and initiates an HTTP request to the target microservice; Specifically, the URL address in the method annotation FeignMapping is obtained through the AOP aspect, such as feign / appid / ability / page. Then, after the application is connected to the zookeeper service discovery, zookeeper obtains the instance-host of each application service instance, such as http: / / 192.168.22.22:8080. The two addresses are spliced together to form http: / / 192.168.22.22:8080 / feign / appid / ability / page, and the interface address to be requested is found, and then an http request is initiated to the target microservice.

[0020] In step 5, the configuration center obtains the response message returned by the target microservice and determines whether it is a normal response. If so, the response message is decrypted and deserialized into a Java entity class, and the return value of the interface is injected into the interface through reflection and forwarded to the microservice that initiated the request. Otherwise, an exception is prompted.

[0021] Specifically, it checks whether the httpCode is 200 or 201. If not, it throws a custom runtime exception RpcException. If everything is normal, it decrypts the response message with national encryption, deserializes the Java entity class, and injects it into the return value of the interface through reflection.

[0022] '200 OK' indicates that the request has been successfully processed by the server and the response contains entity data that matches the request. This applies to all HTTP methods (GET / POST / PUT / DELETE, etc.). The response body may contain complete resource data (such as a GET request) or operation results (such as the submission status returned by POST). By default, clients and proxy servers are allowed to cache response content.

[0023] '201 Created' indicates that the server has successfully created a new resource and clearly identifies the resource location. It is specifically used in resource creation scenarios (such as POST / PUT methods) and must include a Location field in the response header to indicate the URI of the new resource. The response body usually contains a complete description of the new resource (such as its ID, creation time, and other metadata).

[0024] The present invention adopts the above technical solution, which greatly simplifies the development process of inter-service calls through an annotation-driven programming model. Developers do not need to pay attention to the details of the underlying HTTP requests, which lowers the development threshold. The present invention integrates national secret encryption algorithms to ensure the confidentiality and integrity of data during transmission and meet national safety regulations. The present invention implements full-link tracking through trace_id, which greatly improves the observability of the system and facilitates rapid fault location and resolution. The self-developed RPC component of the present invention can be flexibly adjusted according to business needs. Compared with open source components, it is more targeted and easy to expand new functions. With the help of Zookeeper service discovery, the present invention realizes dynamic management and load balancing of microservice instances, thereby improving the availability and performance of the system. The custom exception mechanism of the present invention makes error handling more centralized and efficient, and facilitates maintenance and debugging.

[0025] Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

Claims

1. A remote procedure call method based on the Zookeeper distributed configuration center, characterized by: It includes the following steps: Step 1: The configuration center obtains the interface call requests between different microservices, hides the details of the interface call requests through interface programming, and adds annotations to the interface call requests; Step 2: intercept the method marked with the corresponding annotation through the AOP aspect, obtain the request parameters through reflection and serialize them into JSON; Step 3, use the national encryption to encrypt json, Step 4: The configuration center intercepts and extracts the address information through the AOP aspect to obtain the complete request address and initiates an HTTP request to the target microservice; In step 5, the configuration center obtains the response message returned by the target microservice, decrypts the response message with national encryption, deserializes the Java entity class, injects the return value into the interface through reflection, and forwards it to the microservice that initiated the request.

2. The remote procedure call method based on the Zookeeper distributed configuration center according to claim 1, characterized in that: In step 1, the configuration center obtains the interface call requests between different microservices through the control layer.

3. The remote procedure call method based on the Zookeeper distributed configuration center according to claim 1, characterized in that: In step 3, after encryption with the Chinese secret, the current user information access_token field and trace_id link ID field are transparently transmitted in the http request header.

4. The remote procedure call method based on the Zookeeper distributed configuration center according to claim 1, characterized in that: In step 4, the configuration center obtains the relative URL address of the interface method and the target microservice instance address and concatenates them to form a complete request address.

5. The remote procedure call method based on Zookeeper distributed configuration center according to claim 1, characterized in that: Step 5 specifically includes the following steps: Step 5-1: Get the response message returned by the target microservice; Step 5-2: Determine whether the target microservice responds normally based on the HTTP CODE of the response message; if so, execute step 5-3; otherwise, prompt a response exception; In step 5-3, the response message is decrypted using the national secret code and deserialized into a Java entity class. The return value of the interface is injected into the interface through reflection and forwarded to the microservice that initiated the request.