我调用API的producer写发送消息,但是kafka控制台提示创建topic成功,却没有消息?
kafka
public void sendMessage(){
Properties props = new Properties();
props.put("bootstrap.servers", "192.168.31.96:9092");
props.put("acks", "all");
props.put("retries", 0);
props.put("batch.size", 16384);
props.put("linger.ms", 1);
props.put("buffer.memory", 33554432);
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
KafkaProducer<String,String> producer = new KafkaProducer<>(props);
for (int i = 0; i <10 ; i++) {
String mesg = Integer.toString(i);
ProducerRecord<String, String> records = new ProducerRecord<String,String>("test4",mesg);
producer.send(records);
}
producer.close();
}