|
|
|
@ -99,6 +99,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { |
|
|
|
|
@Override |
|
|
|
|
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { |
|
|
|
|
log.info("加载客户端报文,客户端id{},客户端消息:{}", ctx.channel().id(), msg); |
|
|
|
|
|
|
|
|
|
String data = String.valueOf(msg); |
|
|
|
|
log.info("消息内容:{}", data); |
|
|
|
|
RabbitTemplate rabbitTemplate = SpringBeanFactory.getBean(RabbitTemplate.class); |
|
|
|
@ -210,7 +211,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { |
|
|
|
|
ByteBuf buffer = Unpooled.buffer(); |
|
|
|
|
log.info("开始发送报文:{}", msg); |
|
|
|
|
byte[] bytes = msg.getBytes(StandardCharsets.UTF_8); |
|
|
|
|
buffer.writeBytes(msgBytes); |
|
|
|
|
buffer.writeBytes(bytes); |
|
|
|
|
channel.writeAndFlush(buffer).addListener((ChannelFutureListener) future -> { |
|
|
|
|
if (future.isSuccess()) { |
|
|
|
|
log.info("客户端:{},回写成功:{}", channelId, Arrays.toString(msgBytes)); |
|
|
|
|