public class DubboRpcProtocol extends AbstractProtocol
| Modifier and Type | Field and Description |
|---|---|
protected static byte |
FLAG_EVENT |
protected static byte |
FLAG_REQUEST |
protected static byte |
FLAG_TWOWAY |
| Constructor and Description |
|---|
DubboRpcProtocol() |
| Modifier and Type | Method and Description |
|---|---|
Object |
decode(io.netty.channel.ChannelHandlerContext ctx,
DynamicCompositeByteBuf in,
boolean isDecodingRequest)
客户端/服务端解析请求包成header+body buffer
|
Request |
decodeRequest(Object packet)
服务端反序列化rpc请求
|
Response |
decodeResponse(Object msg,
io.netty.channel.ChannelHandlerContext ctx)
客户端反序列化rpc响应
|
io.netty.buffer.ByteBuf |
encodeRequest(Request request)
客户端序列化请求对象
|
io.netty.buffer.ByteBuf |
encodeResponse(Request request,
Response response)
服务端序列化返回结果。
|
protected byte |
getContentTypeId() |
boolean |
supportHeartbeat()
check if the protocol supports heartbeat packet
|
afterResponseSent, createRequest, createResponse, getRequest, getResponse, isCoexistence, returnChannelBeforeResponseprotected static final byte FLAG_REQUEST
protected static final byte FLAG_TWOWAY
protected static final byte FLAG_EVENT
public Object decode(io.netty.channel.ChannelHandlerContext ctx, DynamicCompositeByteBuf in, boolean isDecodingRequest) throws TooBigDataException, NotEnoughDataException, BadSchemaException
Protocolin - 输入byte bufTooBigDataException - body太大NotEnoughDataException - 可读长度不够,由于粘包拆包问题。BadSchemaException - header格式不对public io.netty.buffer.ByteBuf encodeRequest(Request request) throws Exception
Protocolrequest - 待发送给服务端的对象Exception - 序列化异常public Response decodeResponse(Object msg, io.netty.channel.ChannelHandlerContext ctx) throws Exception
Protocolmsg - header & body的bufctx - netty channel contextException - 反序列化异常public Request decodeRequest(Object packet) throws Exception
Protocolpacket - header & body的bufExceptionpublic io.netty.buffer.ByteBuf encodeResponse(Request request, Response response) throws Exception
Protocolresponse - 服务端要返回给客户端的对象Exception - 序列化异常public boolean supportHeartbeat()
ProtocolsupportHeartbeat in interface ProtocolsupportHeartbeat in class AbstractProtocolprotected byte getContentTypeId()
Copyright © 2020 Baidu, Inc.. All rights reserved.