What exactly is RPC, you might as well write one yourself. Learn about?

RPC is a remote procedure call protocol. RPC main function: communication between heterogeneous distributed projects, so that consumers only need to know the interface, and calling a method remotely is like calling a local method. To make the consumer layer call the remote implementation method only through the interface, the data transmitted between them must be: classes, methods, parameters, return values, and some other transmitted information. When communication is involved, services must be published for client requests. The client wants to execute the method of the unknown implementation, which is implemented through the dynamic proxy. After understanding the use of dynamic proxy, you will find that in the method execution process of dynamic proxy, you can get the required classes, methods, parameters, return values, etc. without executing the real method (invoke method). Execute method parameters. Then transmit these parameters to the remote. After the provider layer receives the parameters of the consumer layer method, it executes the registered class method through reflection. (The provider layer should register the method of the implementation class of the exposed interface into the container for search)

Having said so much, why not implement one yourself?

RPC example of bio multi-threaded communication client-server direct connection

https://github.com/yuyufeng1994/my-rpc/tree/v1

Increase the zookeeper registration discovery, increase the example of Protostuff serialization

https://github.com/yuyufeng1994/my-rpc/tree/v2

An example of increasing Netty and increasing the cluster load

https://github.com/yuyufeng1994/my-rpc

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326101369&siteId=291194637
Recommended