val callback = new Callback {
override def onCompletion(metadata: RecordMetadata, exception: Exception): Unit = {
if (exception != null) {
println(s"Error while sending $metadata")
} else {
println(s"Success: $metadata")
}
}
}
producer.send(r, callback)