@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { if (isRemote(ctx)) { broker.removeLocalSession(routeId); } ctx.fireChannelInactive(); }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { UscConnectionException ex = new UscConnectionException("The channel is closed."); UscRouteIdentifier routeId = ctx.channel().attr(UscPlugin.ROUTE_IDENTIFIER).get(); if (routeId != null) { // this is a channel using remote channel if (broker == null) { broker = UscServiceUtils.getService(UscRouteBrokerService.class); } if (broker != null) { broker.removeLocalSession(routeId); } else { log.error( "Broker service is null! Can't check if it is remote channel message, failed to proccess this exception {}.", ex); } return; } throw ex; }
@Override protected void channelRead0(ChannelHandlerContext ctx, UscException ex) throws Exception { log.trace("UscExceptionHandler channelRead0" + ex); final Throwable t = ex.getCause(); Channel channel = ctx.channel(); UscRouteIdentifier routeId = ctx.channel().attr(UscPlugin.ROUTE_IDENTIFIER).get(); if (routeId != null) { // this is a channel using remote channel if (broker == null) { broker = UscServiceUtils.getService(UscRouteBrokerService.class); } if (broker != null) { broker.removeLocalSession(routeId); } else { log.error( "Broker service is null! Can't check if it is remote channel message, failed to proccess this exception {}.", ex); } return; } SettableFuture<UscSessionImpl> tmp = channel.attr(UscPlugin.SESSION).get(); if (tmp != null) { UscSessionImpl session = tmp.get(); UscChannelImpl connection = session.getChannel(); // connection is down if (t instanceof UscConnectionException) { plugin.getConnectionManager().removeConnection(connection); } else if (t instanceof UscChannelException) { // TODO ; } else if (t instanceof UscSessionException) { connection.removeSession(session.getSessionId()); } } throw ex; }