12.如何解码响应结果
与编码请求类似,其实上篇文章中我们已经发现了对接DubboCodec。
不细细分析了,列出主要代码,直接看代码就可以了。
com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.decode(Channel, ChannelBuffer)// 读取定长heder
com.alibaba.dubbo.rpc.protocol.dubbo.DubboCodec.decodeBody(Channel, InputStream, byte[])// 读取响应体转成DecodeableRpcResult,并将其做作为com.alibaba.dubbo.remoting.exchange.Response的result即data部分
com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(Channel, InputStream)// 解析方法调用返回值
调用栈如下:
DubboCodec.decodeBody(Channel, InputStream, byte[]) line: 105
DubboCodec(ExchangeCodec).decode(Channel, ChannelBuffer, int, byte[]) line: 126
DubboCodec(ExchangeCodec).decode(Channel, ChannelBuffer) line: 87
DubboCountCodec.decode(Channel, ChannelBuffer) line: 46
NettyCodecAdapter$InternalDecoder.messageReceived(ChannelHandlerContext, MessageEvent) line: 134
NettyCodecAdapter$InternalDecoder(SimpleChannelUpstreamHandler).handleUpstream(ChannelHandlerContext, ChannelEvent) line: 80
DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline$DefaultChannelHandlerContext, ChannelEvent) line: 564
DefaultChannelPipeline.sendUpstream(ChannelEvent) line: 559
Channels.fireMessageReceived(Channel, Object, SocketAddress) line: 274
Channels.fireMessageReceived(Channel, Object) line: 261
NioWorker.read(SelectionKey) line: 349
NioWorker.processSelectedKeys(Set<SelectionKey>) line: 280
NioWorker.run() line: 200
本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!