I have a kafka consumer as below, i could able to see the messages on
console, if i go and run on the same machine. but am not able to get the
records here, what could be the problem. Previously i had tried with kafka
some days before it used to work as expected. here also i am able to get
partition info etc but not records.
{tes2=[Partition(topic = tes2, partition = 0, leader = 0, replicas = [0,],
isr = [0,]], elnetty-items=[Partition(topic = elnetty-items, partition = 1,
leader = 1, replicas = [1,2,], isr = [1,2,], Partition(topic =
elnetty-items, partition = 0, leader = 0, replicas = [0,1,], isr = [0,1,]],
__consumer_offsets=[Partition(topic = __consumer_offsets, partition = 23,
leader = 2, replicas = [2,1,0,], isr = [2,1,0,], Partition(topic =
__consumer_offsets, partition = 41, leader = 2, replicas = [2,1,0,], isr =
[2,1,0,], Partition(topic = __consumer_offsets, partition = 32, leader = 2,
replicas = [2,0,1,], isr = [2,0,1,], Partition(topic = __consumer_offsets,
partition = 8, leader = 2, replicas = [2,0,1,], isr = [2,0,1,],
Partition(topic = __consumer_offsets, partition = 44, leader = 2, replicas
= [2,0,1,], isr = [2,0,1,], Partition(topic = __consumer_offsets, partition
= 17, leader = 2, replicas = [2,1,0,], isr = [2,1,0,], Partition(topic =
__consumer_offsets, partition = 35, leader = 2, replicas = [2,1,0,], isr =
[2,1,0,], Partition(topic = __consumer_offsets, partition = 26, leader = 2,
replicas = [2,0,1,], isr = [2,0,1,], Partition(topic = __consumer_offsets,
partition = 11, leader = 2, replicas = [2,1,0,], isr = [2,1,0,],
Partition(topic = __consumer_offsets, partition = 38, leader = 2, replicas
= [2,0,1,], isr = [2,0,1,], Partition(topic = __consumer_offsets, partition
= 29, leader = 2, replicas = [2,1,0,], isr = [2,1,0,], Partition(topic =
__consumer_offsets, partition = 47, leader = 2, replicas = [2,1,0,], isr =
[2,1,0,], Partition(topic = __consumer_offsets, partition = 20, leader = 2,
replicas = [2,0,1,], isr = [2,0,1,], Partition(topic = __consumer_offsets,
partition = 2, leader = 2, replicas = [2,0,1,], isr = [2,0,1,],
Partition(topic = __consumer_offsets, partition = 5, leader = 2, replicas =
[2,1,0,], isr = [2,1,0,], Partition(topic = __consumer_offsets, partition =
14, leader = 2, replicas = [2,0,1,], isr = [2,0,1,], Partition(topic =
__consumer_offsets, partition = 46, leader = 1, replicas = [1,0,2,], isr =
[1,0,2,], Partition(topic = __consumer_offsets, partition = 40, leader = 1,
replicas = [1,0,2,], isr = [1,0,2,], Partition(topic = __consumer_offsets,
partition = 49, leader = 1, replicas = [1,2,0,], isr = [1,2,0,],
Partition(topic = __consumer_offsets, partition = 13, leader = 1, replicas
= [1,2,0,], isr = [1,2,0,], Partition(topic = __consumer_offsets, partition
= 4, leader = 1, replicas = [1,0,2,], isr = [1,0,2,], Partition(topic =
__consumer_offsets, partition = 22, leader = 1, replicas = [1,0,2,], isr =
[1,0,2,], Partition(topic = __consumer_offsets, partition = 31, leader = 1,
replicas = [1,2,0,], isr = [1,2,0,], Partition(topic = __consumer_offsets,
partition = 16, leader = 1, replicas = [1,0,2,], isr = [1,0,2,],
Partition(topic = __consumer_offsets, partition = 7, leader = 1, replicas =
[1,2,0,], isr = [1,2,0,], Partition(topic = __consumer_offsets, partition =
43, leader = 1, replicas = [1,2,0,], isr = [1,2,0,], Partition(topic =
__consumer_offsets, partition = 25, leader = 1, replicas = [1,2,0,], isr =
[1,2,0,], Partition(topic = __consumer_offsets, partition = 34, leader = 1,
replicas = [1,0,2,], isr = [1,0,2,], Partition(topic = __consumer_offsets,
partition = 10, leader = 1, replicas = [1,0,2,], isr = [1,0,2,],
Partition(topic = __consumer_offsets, partition = 37, leader = 1, replicas
= [1,2,0,], isr = [1,2,0,], Partition(topic = __consumer_offsets, partition
= 1, leader = 1, replicas = [1,2,0,], isr = [1,2,0,], Partition(topic =
__consumer_offsets, partition = 28, leader = 1, replicas = [1,0,2,], isr =
[1,0,2,], Partition(topic = __consumer_offsets, partition = 19, leader = 1,
replicas = [1,2,0,], isr = [1,2,0,], Partition(topic = __consumer_offsets,
partition = 45, leader = 0, replicas = [0,2,1,], isr = [0,2,1,],
Partition(topic = __consumer_offsets, partition = 36, leader = 0, replicas
= [0,1,2,], isr = [0,1,2,], Partition(topic = __consumer_offsets, partition
= 27, leader = 0, replicas = [0,2,1,], isr = [0,2,1,], Partition(topic =
__consumer_offsets, partition = 9, leader = 0, replicas = [0,2,1,], isr =
[0,2,1,], Partition(topic = __consumer_offsets, partition = 18, leader = 0,
replicas = [0,1,2,], isr = [0,1,2,], Partition(topic = __consumer_offsets,
partition = 21, leader = 0, replicas = [0,2,1,], isr = [0,2,1,],
Partition(topic = __consumer_offsets, partition = 48, leader = 0, replicas
= [0,1,2,], isr = [0,1,2,], Partition(topic = __consumer_offsets, partition
= 3, leader = 0, replicas = [0,2,1,], isr = [0,2,1,], Partition(topic =
__consumer_offsets, partition = 12, leader = 0, replicas = [0,1,2,], isr =
[0,1,2,], Partition(topic = __consumer_offsets, partition = 30, leader = 0,
replicas = [0,1,2,], isr = [0,1,2,], Partition(topic = __consumer_offsets,
partition = 39, leader = 0, replicas = [0,2,1,], isr = [0,2,1,],
Partition(topic = __consumer_offsets, partition = 15, leader = 0, replicas
= [0,2,1,], isr = [0,2,1,], Partition(topic = __consumer_offsets, partition
= 42, leader = 0, replicas = [0,1,2,], isr = [0,1,2,], Partition(topic =
__consumer_offsets, partition = 33, leader = 0, replicas = [0,2,1,], isr =
[0,2,1,], Partition(topic = __consumer_offsets, partition = 24, leader = 0,
replicas = [0,1,2,], isr = [0,1,2,], Partition(topic = __consumer_offsets,
partition = 6, leader = 0, replicas = [0,1,2,], isr = [0,1,2,],
Partition(topic = __consumer_offsets, partition = 0, leader = 0, replicas =
[0,1,2,], isr = [0,1,2,]]}

public static void main(String[] args) {
Properties props = new Properties();
props.put("bootstrap.servers", "IPPORT");
props.put("group.id", "consumer-tutorial");
props.put("key.deserializer", StringDeserializer.class.getName());
props.put("value.deserializer", StringDeserializer.class.getName());
KafkaConsumer<String, String> consumer = new KafkaConsumer<String,
String>(props);
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("test");
consumer.subscribe(arrayList);
ConsumerRecords<String, String> poll = consumer.poll(1000);
Iterator<ConsumerRecord<String, String>> iterator = poll.iterator();
while (iterator.hasNext()) {
ConsumerRecord<String, String> next = iterator.next();
System.out.println(next);

}
-- 
Yogesh..BG
Senior Software engineer
Sling Media Pvt. Ltd.
PSS Plaza, #6,
Wind Tunnel Road.
Murghesh Palya,
Banglore - 560 017
Contact no: 7760922118

Reply via email to