mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update netty优化业务线程池
This commit is contained in:
@@ -16,6 +16,9 @@ import java.util.concurrent.TimeUnit;
|
||||
@Component
|
||||
public class NettyServerChannelInitializer extends ChannelInitializer<SocketChannel> {
|
||||
|
||||
@Resource
|
||||
private NettyServerHandler nettyServerHandler;
|
||||
|
||||
// 引入业务线程池
|
||||
final EventExecutorGroup businessGroup = new DefaultEventExecutorGroup(16);
|
||||
|
||||
@@ -31,7 +34,7 @@ public class NettyServerChannelInitializer extends ChannelInitializer<SocketChan
|
||||
// 读超时时间设置为30s,0表示不监控
|
||||
pipeline.addLast(new IdleStateHandler(30, 0, 0, TimeUnit.SECONDS));
|
||||
// pipeline.addLast("handler", nettyServerHandler);
|
||||
pipeline.addLast(businessGroup, new NettyServerHandler()); // 消息先进入业务线程池
|
||||
pipeline.addLast(businessGroup, nettyServerHandler); // 消息先进入业务线程池
|
||||
pipeline.addLast(new EchoServerHandler());
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Component
|
||||
public class NettyServerHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
// @Resource
|
||||
// private YKCBusinessService ykcService;
|
||||
@Resource
|
||||
private YKCBusinessService ykcService;
|
||||
|
||||
/**
|
||||
* 管理一个全局map,保存连接进服务端的通道数量
|
||||
@@ -44,7 +44,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
protected static final List<String> notPrintFrameTypeList = Lists.newArrayList(); // "0x03"
|
||||
|
||||
private final YKCBusinessService ykcService = new YKCBusinessServiceImpl();
|
||||
// private final YKCBusinessService ykcService = new YKCBusinessServiceImpl();
|
||||
|
||||
/**
|
||||
* 有客户端连接服务器会触发此函数
|
||||
|
||||
Reference in New Issue
Block a user