@Override public void channelInactive(final ChannelHandlerContext ctx) throws Exception { synchronized (this) { if (active) { listener.connectionDestroyed(channelId(ctx.channel())); active = false; } } }
public NettyServerConnection createConnection(final ChannelHandlerContext ctx, String protocol, boolean httpEnabled) throws Exception super.channelActive(ctx); Listener connectionListener = new Listener();
@Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { // TODO: Think about the id thingy listener.connectionReadyForWrites(channelId(ctx.channel()), ctx.channel().isWritable()); }
@Override public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { ByteBuf buffer = (ByteBuf) msg; handler.bufferReceived(channelId(ctx.channel()), new ChannelBufferWrapper(buffer)); }
@Override public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { if (!active) { return; } // We don't want to log this - since it is normal for this to happen during failover/reconnect // and we don't want to spew out stack traces in that event // The user has access to this exeception anyway via the HornetQException initial cause HornetQException me = HornetQClientMessageBundle.BUNDLE.nettyError(); me.initCause(cause); synchronized (listener) { try { listener.connectionException(channelId(ctx.channel()), me); active = false; } catch (Exception ex) { HornetQClientLogger.LOGGER.errorCallingLifeCycleListener(ex); } } }