Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayushi24041992/6648e30e249f35d15fafa10c104946f6 to your computer and use it in GitHub Desktop.
Save ayushi24041992/6648e30e249f35d15fafa10c104946f6 to your computer and use it in GitHub Desktop.
def sendMessage(recordToSend: Message): Future[Done] = {
try {
val recordToBeProduced = new ProducerRecord(SampleService.MessageTopic, Constants.Empty, message)
val _ = producer.send(recordToBeProduced)
logger.info("Message successfully sent!")
} catch {
case e: Throwable => logger.error("Failed sending message with error {}", e.getMessage)
}
producer.close()
Future.successful(Done)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment