Skip to content

Instantly share code, notes, and snippets.

@adekunleba
Last active October 16, 2018 16:55
Show Gist options
  • Select an option

  • Save adekunleba/fcb0b7cc7d948fd19bceee1ab8a7f9ad to your computer and use it in GitHub Desktop.

Select an option

Save adekunleba/fcb0b7cc7d948fd19bceee1ab8a7f9ad to your computer and use it in GitHub Desktop.
Sample producer to a Kafka cluster
//Given an incoming message to train a Streaming Machine Learning Model
val signaturesToTrainModelsOn = 1 to max
val trainTopic = "signatures"
signaturesToTrainModelsOn.foreach { n =>
streams.send(new ProducerRecord(trainTopic, "sigs", s"$n"))
}
//Given an incoming message to predict
val signaturesToPredictOn = maths.random()
val testTopic = "predictionSignatures"
signaturesToPredictOn.foreach { sig =>
streams.send(new ProducerRecord(testTopic, "testsigs", s"$sig"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment