I have created a topic first_topic
and produced messages to it.
for (int i = 0; i < 10; i++) {
//create producer record
ProducerRecord<String, String> record =
new ProducerRecord<String, String>("first_topic", "hello world " + i);
//send Data
producer.send(record, new Callback() {
public void onCompletion(RecordMetadata recordMetadata, Exception e) {
//executes every time a record is send or an exception occurs
if (e == null) {
//the record was successfully sent
logger.info("Received new meta data \n" +
"Topic : " + recordMetadata.topic() + "\n" +
"Partition : " + recordMetadata.partition() + "\n" +
"OFfset : " + recordMetadata.offset() + "\n" +
"Timestamp : " + recordMetadata.timestamp());
} else {
e.printStackTrace();
logger.error("Error while Producing record ", e);
}
}
});
}
But all messages go to the partition #2. Ideally they should go to all 3 in round robin way. But no. See below. What am I doing wrong?
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group my-third-application
Consumer group 'my-third-application' has no active members.
GROUP TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID
my-third-application first_topic 0 0 0 0 - - -
my-third-application first_topic 1 0 0 0 - - -
my-third-application first_topic 2 10 10 0 - - -