title: Sending messages to Kafka with header using KafkaProducer
body: <p>i am trying to create a simple utility to publish messages to Kafka, but need to pass headers as well along with the message.
  The utility works fine without headers but while trying to send headers i am getting error.</p>
  
  <p>below is sample code that i am using - </p>
  
  <pre><code>public static void main(String[] args) throws Exception {
  
          Properties props = new Properties();
  
          props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "host:port");
          props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
          props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
  
          KafkaProducer&lt;String, String&gt; producer = new KafkaProducer&lt;&gt;(props);
  
          List&lt;Header&gt; headers = Arrays.asList(new RecordHeader("sample_header", "sample_value".getBytes()));
          ProducerRecord&lt;String, String&gt; record = new ProducerRecord&lt;&gt;("TEST", 0, "key", "sample message", headers);
          Future&lt;RecordMetadata&gt; future = producer.send(record);
          System.out.println(future.get());
  
          producer.close();
  
      }
  </code></pre>
  
  <p>the exception i am getting is -</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Magic v1 does not support record headers
      at org.apache.kafka.common.record.MemoryRecordsBuilder.appendWithOffset(MemoryRecordsBuilder.java:385)
      at org.apache.kafka.common.record.MemoryRecordsBuilder.appendWithOffset(MemoryRecordsBuilder.java:424)
      at org.apache.kafka.common.record.MemoryRecordsBuilder.append(MemoryRecordsBuilder.java:481)
      at org.apache.kafka.common.record.MemoryRecordsBuilder.append(MemoryRecordsBuilder.java:504)
      at org.apache.kafka.clients.producer.internals.ProducerBatch.tryAppend(ProducerBatch.java:106)
      at org.apache.kafka.clients.producer.internals.RecordAccumulator.append(RecordAccumulator.java:219)
      at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:791)
      at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:745)
      at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:634)
      at com.test.kafka.KafkaProducerApp.main(KafkaProducerApp.java:45)
  </code></pre>