上一篇讲了consumer端,这次说下provider端.不过老是在client/consumer,server/provider名词间胡乱转换,挺烦的.个人觉得站在通信层更适合讲client/server,不过站在整个rpc上来讲,还是consumer/provider比较合适.好了,回到这个provider端来.
首先我们梳理下server主要的功能有哪些.
当然server肯定是用来接受client发来的消息的.那么client想得到的是她的方法调用的结果.所以,server端要做的就是根据消息来找到对应的方法获得调用结果.
这里我们同样从netty server开始讲起:
boot.group(boss, worker)
.channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.DEBUG))
.option(ChannelOption.SO_BACKLOG, 128)
.childOption(ChannelOption.TCP_NODELAY, true)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
final ChannelPipeline pipe = ch.pipeline();
pipe
.addLast("idleStateHandler",
new IdleStateHandler(BeaconConstants.IDLE_READ_TIMEOUT, 0, 0, TimeUnit