Created
May 28, 2019 08:39
-
-
Save s4kibs4mi/cf45c7e51d43f1fdc0372af8ccccb83d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.kafka.clients.producer.* | |
import java.util.* | |
import org.apache.kafka.common.serialization.StringSerializer | |
import java.lang.Exception | |
fun main(args: Array<String>) { | |
val props = Properties() | |
props[ProducerConfig.BOOTSTRAP_SERVERS_CONFIG] = "localhost:9092" | |
props[ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG] = StringSerializer::class.java.name | |
props[ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG] = StringSerializer::class.java.name | |
val producer = KafkaProducer<Int, String>(props) | |
producer.send(ProducerRecord("users.notification", | |
0, Calendar.getInstance().timeInMillis, null, "hello"), object : Callback { | |
override fun onCompletion(metadata: RecordMetadata?, exception: Exception?) { | |
println("Send Complete") | |
} | |
}) | |
Thread.sleep(120 * 1000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment