cm集成的kafka_2.11-0.10.0-kafka-2.1.0,看了下那个章节的问答,是不是应该在cm中配置 Advertised Host 这个参数呢?
想问下,使用旧的producer API是能正常发送数据的,为什么使用0.10的新的producer API不能发送数据呢?而且不报错,就卡在发送的地方。
Properties props = new Properties();
props.put("bootstrap.servers", "192.168.71.62:9092,192.168.71.63:9092,192.168.71.64: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");
Producer<String, String> producer = new KafkaProducer<>(props);
System.out.println(producer);
for (int i = 0; i < 100; i++) {
String value = "[" + i + "] " + LocalDateTime.now().toString();
System.out.println(value);
Future<RecordMetadata> future = producer.send(new ProducerRecord<>("test-topic", Integer.toString(i), Integer.toString(i)));
System.out.println(future);
}
producer.close();