Created
April 28, 2018 23:52
-
-
Save NeQuissimus/d3826d5a1a167cf784120011e27c22ab to your computer and use it in GitHub Desktop.
Generate Kafka sample messages
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 $ivy.`io.monix::monix-kafka-1x:1.0.0-RC1` | |
import monix.execution.Scheduler.Implicits.{ global => scheduler } | |
import monix.kafka._ | |
import scala.concurrent.duration._ | |
val producerCfg = KafkaProducerConfig.default.copy( | |
bootstrapServers = List("127.0.0.1:9092") | |
) | |
val producer = KafkaProducer[String,String](producerCfg, scheduler) | |
val messages = scheduler.scheduleWithFixedDelay(1.second, 1.second) { producer.send("test", "hello", s"${System.nanoTime}").runAsync } | |
// messages.cancel will stop producing the messages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment