package github.com.AllenDuke.rpc.customer; import github.com.AllenDuke.rpc.netty.NettyClient; import github.com.AllenDuke.rpc.publicSource.Calculator; import github.com.AllenDuke.rpc.publicSource.HelloService; /** * @description 客户端启动类,从NettyClient处获取代理对象,发起RPC * @contact AllenDuke@163.com * @since 2020/2/11 */ public class ClientBootstrap { //netty消费者 private static final NettyClient customer = new NettyClient(); //自定义的消息协议为: #interfaceName#methodName#2#arg1#arg2 //这里用了fastjson public static void main(String[] args) throws Exception { //创建代理对象 HelloService service = (HelloService) customer.getServiceImpl(HelloService.class); String res = service.hello("Allen","Duke",2); Calculator calculator=(Calculator) customer.getServiceImpl(Calculator.class); calculator.add(1,2); calculator.multipy(3,6); } }
用上自己的线程池,实现自己的RPC框架
内容版权声明:除非注明,否则皆为本站原创文章。