<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Kafka + Flume :  Not able to read from KafkaSource, key = null in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Kafka-Flume-Not-able-to-read-from-KafkaSource-key-null/m-p/34965#M11670</link>
    <description>&lt;P&gt;Sorry.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I should have added the "key" for Kafka messages as flume event event headers. Adding hostname interceptor with name as key solved my issue.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;kafkaproducer.sources.tail1.interceptors.i1.type = org.apache.flume.interceptor.HostInterceptor$Builder
kafkaproducer.sources.tail1.interceptors.i1.preserveExisting = false
kafkaproducer.sources.tail1.interceptors.i1.hostHeader = key&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Dec 2015 12:17:32 GMT</pubDate>
    <dc:creator>Sudo</dc:creator>
    <dc:date>2015-12-09T12:17:32Z</dc:date>
    <item>
      <title>Kafka + Flume :  Not able to read from KafkaSource, key = null</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Kafka-Flume-Not-able-to-read-from-KafkaSource-key-null/m-p/34964#M11669</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to accumulate all web logs into HDFS using two sets of flume agents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FlumeAgentProducer&lt;/P&gt;&lt;P&gt;tailsLog --&amp;gt; memory_channel --&amp;gt; Kafka&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FlumeAgentConsumer&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kafka --&amp;gt; memory_channel --&amp;gt; File_Roll / HDFS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Issue is FlumeAgentConsumer is throwing a null pointer exception for key being null.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;2015-12-09 16:48:11,132 ERROR org.apache.flume.source.kafka.KafkaSource: KafkaSource EXCEPTION, {}
java.lang.NullPointerException
	at java.lang.String.&amp;lt;init&amp;gt;(String.java:556)
	at org.apache.flume.source.kafka.KafkaSource.process(KafkaSource.java:105)
	at org.apache.flume.source.PollableSourceRunner$PollingRunner.run(PollableSourceRunner.java:139)
	at java.lang.Thread.run(Thread.java:722)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And from FlumeAgentProducer logs, its clear that messages are written with a null key.&lt;/P&gt;&lt;PRE&gt;2015-12-09 16:34:01,065 DEBUG org.apache.flume.sink.kafka.KafkaSink: event #10
2015-12-09 16:34:01,065 DEBUG org.apache.flume.sink.kafka.KafkaSink: {Event} logtail : null :  0  0      0 3150340 194156 5139772    0    0     0    32  592 1017  1  0 99  0  0	&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to figure out how I can add a key to each kafka message. Please help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attaching Flume configs --&amp;gt; &lt;A href="http://pastebin.com/fbPwdLsb" target="_self"&gt;FlumeAgentConsumer&lt;/A&gt;&amp;nbsp;and &lt;A href="http://pastebin.com/uQXhamh9" target="_self"&gt;FlumeAgentProducer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 09:51:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Kafka-Flume-Not-able-to-read-from-KafkaSource-key-null/m-p/34964#M11669</guid>
      <dc:creator>Sudo</dc:creator>
      <dc:date>2022-09-16T09:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Kafka + Flume :  Not able to read from KafkaSource, key = null</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Kafka-Flume-Not-able-to-read-from-KafkaSource-key-null/m-p/34965#M11670</link>
      <description>&lt;P&gt;Sorry.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I should have added the "key" for Kafka messages as flume event event headers. Adding hostname interceptor with name as key solved my issue.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;kafkaproducer.sources.tail1.interceptors.i1.type = org.apache.flume.interceptor.HostInterceptor$Builder
kafkaproducer.sources.tail1.interceptors.i1.preserveExisting = false
kafkaproducer.sources.tail1.interceptors.i1.hostHeader = key&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Dec 2015 12:17:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Kafka-Flume-Not-able-to-read-from-KafkaSource-key-null/m-p/34965#M11670</guid>
      <dc:creator>Sudo</dc:creator>
      <dc:date>2015-12-09T12:17:32Z</dc:date>
    </item>
  </channel>
</rss>

