Sending Records with Callback in Producer API

Exercise

@jaceklaskowski / StackOverflow / GitHub / LinkedIn
The "Internals" Books: Apache KafkaKafka Streams

Sample Application


            val callback = new Callback {
              override def onCompletion(metadata: RecordMetadata, exception: Exception): Unit = {
                if (exception != null) {
                  println(s"Error while sending $metadata")
                } else {
                  println(s"Success: $metadata")
                }
              }
            }
            producer.send(r, callback)