kafkaProducer.send(new ProducerRecord<>(topic, null, value, key, value), new Callback() {
@Override public void onCompletion(RecordMetadata recordMetadata, Exception e) { success = true; if (e == null) { LOG.info("Successfully sent to topic: " + topic);
} else { Log.error("Exception"); }
send()
method is asynchronous. When called it adds the record to a buffer of pending record sends and immediately returns. This allows the producer to batch together individual records for efficiency.