赞
踩
1、kafka的send 默认发送方式应该是同步,而非异步
public ApacheKafkaClient(String kafkaServers, boolean sync) throws Exception {
super(kafkaServers, sync);
}
查看父类VersionKafkaClient
2、kafka调用send方法有3种方式
//单条发送
public void send(String topic, String message) throws Exception {
if (topic != null && message != null) {
ProducerRecord<String, String> record = new ProducerRecord(topic, message);
if (this.sync) {
this.producer.send(record).get();
} else {
this.producer.send(record);
}
}
}
//批量发送
public void send(String topic, Collection<String> messages) throws Exception {
I
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。