This commit is contained in:
2023-12-15 16:21:20 +08:00
parent 352eaae75f
commit adf14794c9

View File

@@ -104,19 +104,16 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
log.info("[" + channel.remoteAddress() + "] 主动发送push请求信息:{}", wholeMsg); log.info("[" + channel.remoteAddress() + "] 主动发送push请求信息:{}", wholeMsg);
ByteBuf byteBuf = channel.alloc().buffer().writeBytes(writeMsg); ByteBuf byteBuf = channel.alloc().buffer().writeBytes(writeMsg);
ChannelFuture channelFuture = channel.writeAndFlush(byteBuf); ChannelFuture channelFuture = channel.writeAndFlush(byteBuf);
channelFuture.addListener(new ChannelFutureListener() { channelFuture.addListener((ChannelFutureListener) channelFutureListener -> {
@Override // 检查操作的状态
public void operationComplete(ChannelFuture channelFuture) throws Exception { if (channelFutureListener.isSuccess()) {
// 检查操作的状态 log.info("push结果【成功】, remoteAddress:{}, channelId:{}, 帧类型:{}, 报文:{}, ", channel.remoteAddress(), channel.id(), value, wholeMsg);
if (channelFuture.isSuccess()) { } else {
log.info("push结果【成功】, remoteAddress:{}, channelId:{}, 帧类型:{}, 报文:{}, ", channel.remoteAddress(), channel.id(), value, wholeMsg); // 如果发生错误则访问描述原因的Throwable
} else { Throwable cause = channelFutureListener.cause();
// 如果发生错误则访问描述原因的Throwable // cause.printStackTrace();
Throwable cause = channelFuture.cause(); log.info("push结果【失败】, remoteAddress:{}, channelId:{}, 帧类型:{}, 报文:{}", channel.remoteAddress(), channel.id(), value, wholeMsg);
// cause.printStackTrace(); log.error("push发送命令失败", cause);
log.info("push结果【失败】, remoteAddress:{}, channelId:{}, 帧类型:{}, 报文:{}", channel.remoteAddress(), channel.id(), value, wholeMsg);
log.error("push发送命令失败", cause);
}
} }
}); });