Netty如何实现消息推送

网友投稿 223 2022-11-04

Netty如何实现消息推送

Maven依赖

io.netty netty-all 4.1.36.Final

SpringBootApplication

启动器中需要new一个NettyServer,并显式调用启动netty。

@SpringBootApplica

NettyServer

启动的NettyServer,这里进行配置

/** *NettyServerNetty服务器配置 *@authorzhengk

.blog.csdn.net *@da

2019-06-12 */ publicclassNettyServer{ privatefinalintport; publicNettyServer(intport){ this.port=port; } publicvoidstart()throwsException{ EventLoopGroupbossGroup=newNioEventLoopGroup(); EventLoopGroupgroup=newNioEventLoopGroup(); try{ ServerBootstrapsb=newServerBootstrap(); sb.option(ChannelOption.SO_BACKLOG,1024); sb.group(group,bossGroup)//绑定线程池 .channel(N

erve

ocketChannel.class)//指定使用的channel .localAddress(this.port)//绑定监听端口 .childHandler(newChannelInitializer

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Shell脚本---数组
下一篇:Shell脚本---函数
相关文章

 发表评论

暂时没有评论,来抢沙发吧~