You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by 刘林 <li...@chinaums.com> on 2017/12/26 12:54:51 UTC
using long polling for Kafka Producer and Consumer
Hi,
We designed a unified REST gateway to post data to kafka and get data from
kafka, then how can I send and consume the kafka data using long polling for
effieiency. I do not want to new KafkaConsumer/KafkaProducer every time and
close it.
Properties props = kafkaSettings.getDefaultProducerProps();
Producer<String, String> producer = new
KafkaProducer<>(props);
try {
producer.send(new ProducerRecord<String,
String>(topic, value));
} catch (Exception e) {
log.error(e.getMessage());
} finally {
producer.close();
}
Thanks!
Lynn