0

I need to post the consumer record data to kafka topic using producer, While posting it was throwing an error :

Magic v1 does not support add headers...

I checked the broker version also and changed into old jar version. But it always shows an error. for consumer and producer same bootstrap servers host am using, below code I tried

kafka client version is 2.0.1 zkclient version is 0.10

consumer code sender is method name

for (ConsumerRecord<String, String> record : records) { sender(record.key(), record.value()); }

producer code :

public static void sender(String key, String Value) throws Exception {
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
KafkaProducer<String, String> producer = new KafkaProducer<String, String>(props);
ProducerRecord<String, String> prodrecord = new ProducerRecord<String, String>(TopicName, key, Value);
producer.send(prodrecord);
}

Thanks in advance

Jin Lee
  • 3,194
  • 12
  • 46
  • 86
tisispa1
  • 203
  • 2
  • 3
  • 16
  • From what I see, you're instantiating a producer for each record you read , it seems not normal to me.. Are you sure of the code you did post ? – Yannick Aug 14 '19 at 10:45
  • @Yannick yes...!! It's there any problem in producer code I don't think so..!! – tisispa1 Aug 14 '19 at 11:49
  • yes first, you should instantiate your producer before the loop and then call send only in the loop – Yannick Aug 14 '19 at 11:55
  • @Yannick ok but my question is why it was throwing magic v1 does not support record headers exception...?? – tisispa1 Aug 14 '19 at 11:57
  • What is the version of your kafka broker ? Check out [this question](https://stackoverflow.com/questions/55710773/getting-magic-v1-does-not-support-record-headers-when-producing-message) and the answer in its comment – Arnaud Claudel Aug 14 '19 at 16:19
  • @ArnaudClaudel broker version 0.10 – tisispa1 Aug 14 '19 at 16:20
  • Then it's a duplicate of the question I linked, you need to upgrade your broker – Arnaud Claudel Aug 14 '19 at 16:23
  • @ArnaudClaudel no I tried everything...!! Without upgrading how to achieve that..!! Any possible way to avoid headers while producing message – tisispa1 Aug 14 '19 at 16:25

0 Answers0