I did a fresh install of Apache Kafka 0.10.1.0.
I was able to send / receive messages on the command line.
Using the Java Producer / Consumer example, I cannot recognize the group.id parameter in the user example.
Let me know how to fix this problem.
The following is an example of a consumer that I used:
public static void main(String[] args) { Properties props = new Properties(); props.put("bootstrap.servers", "localhost:9092"); props.put("group.id", "my-topic"); props.put("enable.auto.commit", "true"); props.put("auto.commit.interval.ms", "1000"); props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props); try { consumer.subscribe(Arrays.asList("my-topic")); ConsumerRecords<String, String> records = consumer.poll(100); System.err.println("records size=>"+records.count()); for (ConsumerRecord<String, String> record : records) System.out.printf("offset = %d, key = %s, value = %s%n", record.offset(), record.key(), record.value()); } catch (Exception ex){ ex.printStackTrace(); } finally { consumer.close(); } }
After running the command for the user, I can see the messages (on the console) sent by the manufacturer. But could not see the messages from the java program
bin \ windows \ kafka-console-consumer.bat --bootstrap-server localhost: 9092 --topic my-topic --from-begin
source share