title: Kafka Producer API - onCompletion
body: <p>Trying to understand the Java producer API . onCompletion means what ? Help me understand for the same . </p>
  
  <p>Reference : 
  <a href="https://kafka.apache.org/0110/javadoc/index.html?org/apache/kafka/clients/producer/KafkaProducer.html" rel="nofollow noreferrer">https://kafka.apache.org/0110/javadoc/index.html?org/apache/kafka/clients/producer/KafkaProducer.html</a></p>
  
  <pre><code>ProducerRecord&lt;byte[],byte[]&gt; record = new ProducerRecord&lt;byte[],byte[]&gt;("the-topic", key, value);
   producer.send(myRecord,
                 new Callback() {
                     public void onCompletion(RecordMetadata metadata, Exception e) {
                         if(e != null) {
                            e.printStackTrace();
                         } else {
                            System.out.println("The offset of the record we just sent is: " + metadata.offset());
                         }
                     }
                 });
  </code></pre>