NettyClientMain.java 893 字节
Newer Older
S
shuang.kou 已提交
1 2
package github.javaguide;

S
shuang.kou 已提交
3
import github.javaguide.remoting.transport.ClientTransport;
4
import github.javaguide.proxy.RpcClientProxy;
5
import github.javaguide.remoting.transport.netty.client.NettyClientTransport;
S
shuang.kou 已提交
6

S
shuang.kou 已提交
7 8 9 10 11 12
/**
 * @author shuang.kou
 * @createTime 2020年05月10日 07:25:00
 */
public class NettyClientMain {
    public static void main(String[] args) {
13
        ClientTransport rpcClient = new NettyClientTransport();
S
shuang.kou 已提交
14 15 16
        RpcClientProxy rpcClientProxy = new RpcClientProxy(rpcClient);
        HelloService helloService = rpcClientProxy.getProxy(HelloService.class);
        String hello = helloService.hello(new Hello("111", "222"));
17 18
        //如需使用 assert 断言,需要在 VM options 添加参数:-ea
        assert "Hello description is 222".equals(hello);
19
        String hello2 = helloService.hello(new Hello("111", "222"));
20
        System.out.println(hello2);
S
shuang.kou 已提交
21 22
    }
}