Examples of messageSet()


Examples of kafka.javaapi.FetchResponse.messageSet()

        }
        // get data back from Kafka
        SimpleConsumer consumer = new SimpleConsumer(config.hostName(), config.port(), 100000, 100000, "clientId");
        FetchResponse response = consumer.fetch(new FetchRequestBuilder().addFetch(TOPIC_NAME, 0, 0, 100000).build());

        List<MessageAndOffset> messageSet = Lists.newArrayList(response.messageSet(TOPIC_NAME, 0).iterator());
        assertEquals("Should have fetched 2 messages", 2, messageSet.size());

        for( int i=0; i<messageSet.size(); i++ ){
            // ensure that received message was one that was sent
            String receivedPayload = new String(extractMessage(messageSet, i));
View Full Code Here

Examples of kafka.javaapi.FetchResponse.messageSet()

        log.info("Error Code generated : "
            + fetchResponse.errorCode(kafkaRequest.getTopic(),
                kafkaRequest.getPartition()));
        return false;
      } else {
        ByteBufferMessageSet messageBuffer = fetchResponse.messageSet(
            kafkaRequest.getTopic(), kafkaRequest.getPartition());
        lastFetchTime = (System.currentTimeMillis() - tempTime);
        log.debug("Time taken to fetch : "
            + (lastFetchTime / 1000) + " seconds");
        log.debug("The size of the ByteBufferMessageSet returned is : " + messageBuffer.sizeInBytes());
View Full Code Here

Examples of kafka.javaapi.FetchResponse.messageSet()

        }
        findLeader();
        continue;
      }

      return fetchResponse.messageSet(topic, partition);
    }
    String message = String.format("Error fetching data from broker %s:%d for topic %s, partition %d. Error code: %d",
                                   consumer.host(), consumer.port(), topic, partition, errorCode);
    LOG.error(message);
    throw new RuntimeException(message);
View Full Code Here

Examples of kafka.javaapi.FetchResponse.messageSet()

//            long startOffset = getOffset(topic, partition, config.startOffsetTime);
//            offset = startOffset;
//          }
          throw new KafkaException("fetch data from kafka topic["+topic+"] partition["+partition+"] error:" + code);
        }else {
          ByteBufferMessageSet msgs =  fetchResponse.messageSet(topic, partition);
          return msgs;
        }
  }
 
 
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.