Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelFuture.addListener()


         try {
            FullAbortRequest far = new FullAbortRequest();
            far.startTimestamp = transactionId;

            ChannelFuture f = channel.write(far);
            f.addListener(new ChannelFutureListener() {
                  public void operationComplete(ChannelFuture future) {
                     if (!future.isSuccess()) {
                        error(new IOException("Error writing to socket"));
                     } else {
                        cb.complete();
View Full Code Here


    }

    private void write404(MessageEvent e) {
      HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND);
      ChannelFuture future = e.getChannel().write(response);
      future.addListener(ChannelFutureListener.CLOSE);
    }

    private void writeResponse(MessageEvent e) {
      HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
      response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "application/json; charset=UTF-8");
View Full Code Here

      } catch (IOException e1) {
        LOG.error("error writing resource report", e1);
      }
      response.setContent(content);
      ChannelFuture future = e.getChannel().write(response);
      future.addListener(ChannelFutureListener.CLOSE);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
      e.getChannel().close();
View Full Code Here

        // Finally, write the Subscribe request through the Channel.
        if (logger.isDebugEnabled())
            logger.debug("Writing a SubUnsub request to host: " + HedwigClientImpl.getHostFromChannel(channel)
                         + " for pubSubData: " + pubSubData);
        ChannelFuture future = channel.write(pubsubRequestBuilder.build());
        future.addListener(new WriteCallback(pubSubData, client));
    }

    /**
     * This is a helper method to write a consume message to the server after a
     * subscribe Channel connection is made to the server and messages are being
View Full Code Here

        // message if there was a problem writing the consume request.
        if (logger.isDebugEnabled())
            logger.debug("Writing a Consume request to host: " + HedwigClientImpl.getHostFromChannel(channel)
                         + " with messageSeqId: " + messageSeqId + " for pubSubData: " + pubSubData);
        ChannelFuture future = channel.write(pubsubRequestBuilder.build());
        future.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                if (!future.isSuccess()) {
                    logger.error("Error writing a Consume request to host: " + HedwigClientImpl.getHostFromChannel(channel)
                                 + " with messageSeqId: " + messageSeqId + " for pubSubData: " + pubSubData);
View Full Code Here

        // Now make the TopicSubscriber Channel readable (it is set to not be
        // readable when the initial subscription is done). Note that this is an
        // asynchronous call. If this fails (not likely), the futureListener
        // will just log an error message for now.
        ChannelFuture future = topicSubscriberChannel.setReadable(true);
        future.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                if (!future.isSuccess()) {
                    logger.error("Unable to make subscriber Channel readable in startDelivery call for topic: "
                                 + topic.toStringUtf8() + ", subscriberId: " + subscriberId.toStringUtf8());
View Full Code Here

        // Now make the TopicSubscriber channel not-readable. This will buffer
        // up messages if any are sent from the server. Note that this is an
        // asynchronous call. If this fails (not likely), the futureListener
        // will just log an error message for now.
        ChannelFuture future = topicSubscriberChannel.setReadable(false);
        future.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                if (!future.isSuccess()) {
                    logger.error("Unable to make subscriber Channel not readable in stopDelivery call for topic: "
                                 + topic.toStringUtf8() + ", subscriberId: " + subscriberId.toStringUtf8());
View Full Code Here

            Channel channel = topicSubscriber2Channel.get(topicSubscriber);
            topicSubscriber2Channel.remove(topicSubscriber);
            // Close the subscribe channel asynchronously.
            HedwigClientImpl.getResponseHandlerFromChannel(channel).channelClosedExplicitly = true;
            ChannelFuture future = channel.close();
            future.addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    if (!future.isSuccess()) {
                        logger.error("Failed to close the subscription channel for topic: " + topic.toStringUtf8()
                                     + ", subscriberId: " + subscriberId.toStringUtf8());
View Full Code Here

        bootstrap.setOption("tcpNoDelay", true);
        bootstrap.setOption("keepAlive", true);

        // Start the connection attempt to the input server host.
        ChannelFuture future = bootstrap.connect(serverHost);
        future.addListener(new ConnectCallback(pubSubData, serverHost, this));
    }

    /**
     * Helper method to store the topic2Host mapping in the HedwigClient cache
     * map. This method is assumed to be called when we've done a successful
View Full Code Here

        bootstrap.setOption("tcpNoDelay", conf.getClientTcpNoDelay());
        bootstrap.setOption("keepAlive", true);

        ChannelFuture future = bootstrap.connect(addr);

        future.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                int rc;
                Queue<GenericCallback<Void>> oldPendingOps;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.