Learn from the ants classroom project
dubbo schematics
The idea to build dubbo rpc Remote Invocation Framework
Build dubbo-server
- Custom rpc notes in class need to register to add on zk, need to register to identify such zk
- The local service registered to zk
- Node on the zk to support multiple cluster to prepare for the situation after the
- Create server-side netty, and add the appropriate handler
- By appropriate handler to resolve, and the respective method is performed using reflection
- The results reflected get the call, then corresponding to the client can be
Build dubbo-client
- Adding service discovery module
- Add a load balancer module (using strategy pattern)
- According to the consumer side gets serviceName dependent interface to get the list of services on zk
- Then select a node based on load balancing strategy
- Packaging rpcRequest class, serviceName, methodName, parameterTypes, args good package
- The encapsulated using NettyClient rpcRequest class to NettyServer, wait for the results of the corresponding
- After obtaining the results, then the results can be returned to the caller at
Project Difficulties:
-
Only when the client calls the interface, there is no instance, is how the calling
Using jdk dynamic proxy, or proxy dynamically generated proxy class cglib
-
What netty network transmission objects need to pay attention?
Note that the object serialization and anti-serialization
-
The service registry need to pay attention to what the zk?
The need for registration path is encoded. Otherwise, add a node is to go wrong
-
Difference resful protocol format and json protocol format?
rpc style uses a restful, the sequence agreement MessagePack is generally used, data transfer is: [value1, value2, value3], is more advantageous in that space saving, the disadvantage that is not flexible enough
Serializing http protocol generally json, json takes the form of key-value to stored values. Advantages: high readability, and high flexibility. Disadvantages: space is relatively large bandwidth,