Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelFutureListener


            callback.done(true);
            return true;
        }

        // write body
        NettyHelper.writeBodyAsync(channel, null, body, exchange, new ChannelFutureListener() {
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                LOG.trace("Operation complete {}", channelFuture);
                if (!channelFuture.isSuccess()) {
                    // no success the set the caused exception and signal callback and break
                    exchange.setException(channelFuture.getCause());
View Full Code Here


    }

    private Channel openChannel(ChannelFuture channelFuture) throws Exception {
        // wait until until the operation is complete
        final CountDownLatch latch = new CountDownLatch(1);
        channelFuture.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                LOG.debug("Operation complete {}", channelFuture);
                latch.countDown();
            }
View Full Code Here

        // setup state as attachment on the channel, so we can access the state later when needed
        channel.setAttachment(new NettyCamelState(producerCallback, exchange));

        // write body
        NettyHelper.writeBodyAsync(LOG, channel, null, body, exchange, new ChannelFutureListener() {
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                LOG.trace("Operation complete {}", channelFuture);
                if (!channelFuture.isSuccess()) {
                    // no success the set the caused exception and signal callback and break
                    exchange.setException(channelFuture.getCause());
View Full Code Here

        if (LOG.isTraceEnabled()) {
            LOG.trace("Waiting for operation to complete {} for {} millis", channelFuture, configuration.getConnectTimeout());
        }
        // here we need to wait it in other thread
        final CountDownLatch channelLatch = new CountDownLatch(1);
        channelFuture.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture cf) throws Exception {
                channelLatch.countDown();
            }
        });
View Full Code Here

    protected void removeChannel(int partition) {
        Channel c = partitionChannelMap.remove(partition);
        if (c == null) {
            return;
        }
        c.close().addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                if (future.isSuccess())
                    channels.remove(future.getChannel());
                else
View Full Code Here

        }

        public void exceptionCaught(ChannelHandlerContext context, ExceptionEvent event) {
            logger.error("Error", event.getCause());
            Channel c = context.getChannel();
            c.close().addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    if (future.isSuccess())
                        channels.remove(future.getChannel());
                    else
View Full Code Here

            if (channel.socket.connect(remoteAddress)) {
                NioWorker worker = nextWorker();
                channel.setWorker(worker);
                worker.register(channel, future);
            } else {
                future.addListener(new ChannelFutureListener() {
                    public void operationComplete(ChannelFuture future) {
                        if (future.isCancelled()) {
                            channel.close();
                        }
                    }
View Full Code Here

        if (!engine.isInboundDone()) {
            if (sentCloseNotify.compareAndSet(false, true)) {
                engine.closeOutbound();
                synchronized (closeFutures) {
                    ChannelFuture closeNotifyFuture = wrapNonAppData(context, e.getChannel());
                    closeNotifyFuture.addListener(new ChannelFutureListener() {
                        public void operationComplete(ChannelFuture closeNotifyFuture) throws Exception {
                            closeFutures.offer(e.getFuture());
                        }
                    });
                }
View Full Code Here

        context.sendDownstream(e);
    }

    private static ChannelFuture newHandshakeFuture(Channel channel) {
        ChannelFuture future = future(channel);
        future.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future)
                    throws Exception {
                if (!future.isSuccess()) {
                    fireExceptionCaught(future.getChannel(), future.getCause());
                }
View Full Code Here

          // Check if we can find the right handshaker for the requested version
          if (handshaker == null) {
              wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.getChannel());
          } else {
              // fuehre den Handshake
              handshaker.handshake(ctx.getChannel(), req).addListener(new ChannelFutureListener() {
                  @Override
                  public void operationComplete(ChannelFuture future) throws Exception {
                      if(!future.isSuccess()) {
                          // Handshake failed with an Exception, forward it to the other handlers in the chain
                          Channels.fireExceptionCaught(future.getChannel(), future.getCause());
View Full Code Here

TOP

Related Classes of org.jboss.netty.channel.ChannelFutureListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.