netty channelactive方法只在连接时调用吗
1个回答
展开全部
@Override
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
//断开连接删除channel
channels.remove(SolrTcpEnum.QUERY);
final EventLoop loop = ctx.channel().eventLoop();
loop.schedule(new Runnable() {
@Override
public void run() {
log.info("Reconnecting to Solr Server [{}:{}]",SolrClient.HOST,SolrClient.PORT);
try {
SolrClient.createBootstrap(new Bootstrap(), loop);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}, RECONNECT_DELAY, TimeUnit.SECONDS);
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
channels.put(SolrTcpEnum.QUERY, ctx);
// if(channels.get(SolrTcpEnum.QUERY)==null){
// channels.put(SolrTcpEnum.QUERY, ctx);
// }else if(channels.get(SolrTcpEnum.PUT)==null){
// channels.put(SolrTcpEnum.PUT, ctx);
// }
}
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
//断开连接删除channel
channels.remove(SolrTcpEnum.QUERY);
final EventLoop loop = ctx.channel().eventLoop();
loop.schedule(new Runnable() {
@Override
public void run() {
log.info("Reconnecting to Solr Server [{}:{}]",SolrClient.HOST,SolrClient.PORT);
try {
SolrClient.createBootstrap(new Bootstrap(), loop);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}, RECONNECT_DELAY, TimeUnit.SECONDS);
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
channels.put(SolrTcpEnum.QUERY, ctx);
// if(channels.get(SolrTcpEnum.QUERY)==null){
// channels.put(SolrTcpEnum.QUERY, ctx);
// }else if(channels.get(SolrTcpEnum.PUT)==null){
// channels.put(SolrTcpEnum.PUT, ctx);
// }
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询