Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelFutureListener


            if (consumer.getConfiguration().isTextline()) {
                body = NettyHelper.getTextlineBody(body, exchange, consumer.getConfiguration().getDelimiter(), consumer.getConfiguration().isAutoAppendDelimiter());
            }

            // we got a body to write
            ChannelFutureListener listener = createResponseFutureListener(consumer, exchange, messageEvent.getRemoteAddress());
            if (consumer.getConfiguration().isTcp()) {
                NettyHelper.writeBodyAsync(LOG, messageEvent.getChannel(), null, body, exchange, listener);
            } else {
                NettyHelper.writeBodyAsync(LOG, messageEvent.getChannel(), messageEvent.getRemoteAddress(), body, exchange, listener);
            }
View Full Code Here


            // Need to specify the remoteAddress here
            remoteAddress = new InetSocketAddress(configuration.getHost(), configuration.getPort());
        }
       
        // write body
        NettyHelper.writeBodyAsync(LOG, channel, remoteAddress, 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

      }
     
      ChannelFuture future = bootstrap.connect(new InetSocketAddress(host,
          port));
     
      future.addListener(new ChannelFutureListener()
      {
        @Override
        public void operationComplete(ChannelFuture future) throws Exception
        {
          ChannelBuffer loginBuffer = getLoginBuffer("Zombie_ROOM_1_REF_KEY_1",writeSocketAddressToBuffer(udpLocalAddress));
View Full Code Here

        // Write the connect statement. TODO repeat till we get start.
        System.out.println("Events.CONNECT: " + Events.CONNECT);
        ChannelBuffer buf = NettyUtils.createBufferForOpcode(Events.CONNECT);
       
        ChannelFuture future = c.write(buf, serverAddress);
        future.addListener(new ChannelFutureListener()
        {
          @Override
          public void operationComplete(ChannelFuture future) throws Exception
          {
            if(!future.isSuccess())
View Full Code Here

//    try {
//      channelFuture.await(10, TimeUnit.SECONDS);
//    } catch (InterruptedException e) {
//    }
   
    channelFuture.addListener(new ChannelFutureListener() {
          public void operationComplete(ChannelFuture future) {
              if(future.isSuccess()) {
                  //warn的日志,打点为了对每轮执行情况进行观察
                  if (logger.isWarnEnabled())
                  {
View Full Code Here

//    try {
//      channelFuture.await(10, TimeUnit.SECONDS);
//    } catch (InterruptedException e) {
//    }
   
    channelFuture.addListener(new ChannelFutureListener() {
          public void operationComplete(ChannelFuture future) {
              if (!future.isSuccess())
              {
                logger.error("Mastersocket write error.",future.getCause());
                  future.getChannel().close();
View Full Code Here

 
  @Override
  public void echoSendMonitorInfo(SendMonitorInfoResponseEvent event) {
   
    ChannelFuture channelFuture = ((Channel)event.getChannel()).write(event);
    channelFuture.addListener(new ChannelFutureListener() {
          public void operationComplete(ChannelFuture future) {
              if (!future.isSuccess())
              {
                logger.error("Mastersocket write error.",future.getCause());
                  future.getChannel().close();
View Full Code Here

      ChannelFuture channelFuture = channel.write(requestEvent);

      // why ??, 这里不必等待
      //channelFuture.await(10, TimeUnit.SECONDS);

      channelFuture.addListener(new ChannelFutureListener() {
        public void operationComplete(ChannelFuture future) {
          if (!future.isSuccess()) {
            responseQueue.remove(event.getSequence());
//            slaveEventTimeQueue.remove(event);
           
View Full Code Here

            jobResponseEvent.setChannel(channel);
            final long start = System.currentTimeMillis();
            ChannelFuture channelFuture = channel.write(jobResponseEvent);
//            channelFuture.await(10, TimeUnit.SECONDS);

            channelFuture.addListener(new ChannelFutureListener() {
                public void operationComplete(ChannelFuture future) {
                    if (!future.isSuccess()) {
                        responseQueue.remove(event.getSequence());
//                        slaveEventTimeQueue.remove(event);
                       
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.