netty 的channelRead 方法不执行,但是channelReadComplete 方法执行了:
public class MessageForwardInboundHandler extends ChannelInboundHandlerAdapter {
@Autowired
BusinessConfig businessConfig;
@Autowired
CommonHandlerFactory handlerFactory;
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
Message message = (Message)msg;
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>channelRead执行>>>>>>>>>>>>>>>>>>");
if(null == handlerFactory.getHandler((int)message.getMsgHead().getMsgId())){
log.warn("暂不支持此类型消息:" + ByteArrayUtil.short2HexStr(message.getMsgHead().getMsgId()));
return;
}
handlerFactory.getHandler((int)message.getMsgHead().getMsgId()).handler(ctx,message);
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
log.info("数据读取完成");
super.channelReadComplete(ctx);
}
}