Merge pull request #365 from shining-stars-lk/develop

Optimized netty functions
pull/368/head
Huahua Yin 2 years ago committed by GitHub
commit e41641c6f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -68,8 +68,8 @@ public class MonitorNettyServer {
serverBootstrap.group(bossGroup, workGroup) serverBootstrap.group(bossGroup, workGroup)
.channel(NioServerSocketChannel.class) .channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.INFO)) .handler(new LoggingHandler(LogLevel.INFO))
// childHandler的任务由workGroup来执行 // BossGroup the Thread group is responsible for connection events
// 如果是handler则由bossGroup来执行 // WorkGroup the thread group is responsible for read and write events
.childHandler(new ChannelInitializer<SocketChannel>() { .childHandler(new ChannelInitializer<SocketChannel>() {
@Override @Override

@ -43,7 +43,6 @@ import org.springframework.stereotype.Component;
*/ */
@Slf4j @Slf4j
@AllArgsConstructor @AllArgsConstructor
@Component
public class NettyConnectSender implements MessageSender { public class NettyConnectSender implements MessageSender {
private ServerNettyAgent serverNettyAgent; private ServerNettyAgent serverNettyAgent;
@ -59,7 +58,7 @@ public class NettyConnectSender implements MessageSender {
.handler(new ChannelInitializer<SocketChannel>() { .handler(new ChannelInitializer<SocketChannel>() {
@Override @Override
protected void initChannel(SocketChannel ch) throws Exception { protected void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline(); ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new ObjectEncoder()); pipeline.addLast(new ObjectEncoder());
pipeline.addLast(new ObjectDecoder(Integer.MAX_VALUE, pipeline.addLast(new ObjectDecoder(Integer.MAX_VALUE,
@ -71,8 +70,6 @@ public class NettyConnectSender implements MessageSender {
bootstrap.connect(serverNettyAgent.getNettyServerAddress(), serverNettyAgent.getNettyServerPort()).sync(); bootstrap.connect(serverNettyAgent.getNettyServerAddress(), serverNettyAgent.getNettyServerPort()).sync();
} catch (Exception e) { } catch (Exception e) {
log.error("netty send error ", e); log.error("netty send error ", e);
} /* }
* finally { eventLoopGroup.shutdownGracefully(); }
*/
} }
} }

@ -50,7 +50,7 @@
<rocketmq.version>2.2.2</rocketmq.version> <rocketmq.version>2.2.2</rocketmq.version>
<tomcat-embed-core.version>9.0.55</tomcat-embed-core.version> <tomcat-embed-core.version>9.0.55</tomcat-embed-core.version>
<spring-cloud-starter-stream-rocketmq.version>2.2.6.RELEASE</spring-cloud-starter-stream-rocketmq.version> <spring-cloud-starter-stream-rocketmq.version>2.2.6.RELEASE</spring-cloud-starter-stream-rocketmq.version>
<netty.version>4.1.42.Final</netty.version> <netty.version>4.1.56.Final</netty.version>
<spring-cloud-starter-netflix-hystrix.version>2.2.9.RELEASE</spring-cloud-starter-netflix-hystrix.version> <spring-cloud-starter-netflix-hystrix.version>2.2.9.RELEASE</spring-cloud-starter-netflix-hystrix.version>
<!-- Maven & Build --> <!-- Maven & Build -->

Loading…
Cancel
Save