Netty] [04 - rpc use netty frame structures of similar dubbo

Learn from the ants classroom project

project address:

dubbo schematicsHere Insert Picture Description

The idea to build dubbo rpc Remote Invocation Framework

Build dubbo-server

  1. Custom rpc notes in class need to register to add on zk, need to register to identify such zk
  2. The local service registered to zk
  3. Node on the zk to support multiple cluster to prepare for the situation after the
  4. Create server-side netty, and add the appropriate handler
  5. By appropriate handler to resolve, and the respective method is performed using reflection
  6. The results reflected get the call, then corresponding to the client can be

Build dubbo-client

  1. Adding service discovery module
  2. Add a load balancer module (using strategy pattern)
  3. According to the consumer side gets serviceName dependent interface to get the list of services on zk
  4. Then select a node based on load balancing strategy
  5. Packaging rpcRequest class, serviceName, methodName, parameterTypes, args good package
  6. The encapsulated using NettyClient rpcRequest class to NettyServer, wait for the results of the corresponding
  7. After obtaining the results, then the results can be returned to the caller at

Project Difficulties:

  1. 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

  2. What netty network transmission objects need to pay attention?

    Note that the object serialization and anti-serialization

  3. 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

  4. 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,

Published 26 original articles · won praise 1 · views 1452

Guess you like

Origin blog.csdn.net/qq_42556214/article/details/104539655