# NettyRpc **Repository Path**: jcliang/NettyRpc ## Basic Information - **Project Name**: NettyRpc - **Description**: 一个轻量级分布式RPC框架--NettyRpc http://www.cnblogs.com/luxiaoxun/p/5272384.html 根据 黄勇老师的 项目 修改过来的 来源:luxiaoxun https://github.com/luxiaoxun/NettyRpc - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-10-20 - **Last Updated**: 2021-11-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NettyRpc An RPC framework based on Netty, ZooKeeper and Spring 中文详情:[Chinese Details](http://www.cnblogs.com/luxiaoxun/p/5272384.html) ### Features: * Simple code and framework * Non-blocking asynchronous call and Synchronous call support * Long lived persistent connection * High availability, load balance and failover * Service Discovery support by ZooKeeper #### How to use 1. Define an interface: public interface HelloService { String hello(String name); String hello(Person person); } 2. Implement the interface with annotation @RpcService: @RpcService(HelloService.class) public class HelloServiceImpl implements HelloService { @Override public String hello(String name) { return "Hello! " + name; } @Override public String hello(Person person) { return "Hello! " + person.getFirstName() + " " + person.getLastName(); } } 3. Run zookeeper 4. Start server: RpcBootstrap 5. Use the client: ServiceDiscovery serviceDiscovery = new ServiceDiscovery("127.0.0.1:2181"); final RpcClient rpcClient = new RpcClient(serviceDiscovery); // Sync call HelloService helloService = rpcClient.create(HelloService.class); String result = helloService.hello("World"); // Async call IAsyncObjectProxy client = rpcClient.createAsync(HelloService.class); RPCFuture helloFuture = client.call("hello", "World"); String result = (String) helloFuture.get(3000, TimeUnit.MILLISECONDS);