send Await
suspend fun <A, B> KafkaProducer<A, B>.sendAwait(record: ProducerRecord<A, B>): RecordMetadata
Content copied to clipboard
Sends a record to a Kafka topic in a suspending way.
fun main() = runBlocking<Unit> {
KafkaProducer(Properties(), StringSerializer(), StringSerializer()).use { producer ->
producer.sendAwait(ProducerRecord("topic-name", "message #1"))
producer.sendAwait(ProducerRecord("topic-name", "message #2"))
}
}Content copied to clipboard