1 Star 2 Fork 56

bugstack虫洞栈/物联

forked from baolinking/物联网关 
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
ToClientDesign.java 2.14 KB
Copy Edit Raw Blame History
baolinking authored 2019-09-17 13:51 +08:00 . 物联网采集系统源码提交
/**
*
*/
package connect;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import divpro.DivChannelInitializer;
import freeconfig.GetProperties;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import jedis.Jedisclusters;
/**
* @Description:
* 心跳时间,不同设备或厂家的心跳时间是不同的,按配置更改就行
* @author: wbl
* @date: 2019年8月30日 上午10:04:44
*/
@Configuration
public class ToClientDesign implements Runnable{
private int poolNum = 0;
@Resource
public static Jedisclusters jedisCluster;
public ToClientDesign(int poolnum){
this.poolNum = poolnum;
}
@Override
public void run() {
EventLoopGroup bossGroup = new NioEventLoopGroup(ConfigDesign.BIZGROUPSIZE);
EventLoopGroup workerGroup = new NioEventLoopGroup(ConfigDesign.BIZTHREADSIZE);
try {
ServerBootstrap gateServer = new ServerBootstrap();
gateServer.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.option(ChannelOption.SO_BACKLOG, ConfigDesign.CACHESIZE)
.childHandler(new DivChannelInitializer());
String port = GetProperties.getValue("client.port");
System.out.println("read client config:"+port);
ChannelFuture f = gateServer.bind(Integer.parseInt(port)).sync();
System.out.println("bind: ["+new Date()+"] 服务器开始监听端口"+port+",等待客户端连接.........");
f.channel().closeFuture().sync();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
/**优雅退出,释放线程池资源*/
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/bugstack_cn/gateway.git
git@gitee.com:bugstack_cn/gateway.git
bugstack_cn
gateway
物联
master

Search