Spring Kafka Producer not sending to Kafka 1.0.0 (Magic v1 does not support record headers)

后端 未结 4 2199
青春惊慌失措
青春惊慌失措 2021-02-14 04:08

I am using this docker-compose setup for setting up Kafka locally: https://github.com/wurstmeister/kafka-docker/

docker-compose up works fine, creating topi

4条回答
  •  旧时难觅i
    2021-02-14 04:25

    you are using kafka version <=0.10.x.x once you using using this, you must set JsonSerializer.ADD_TYPE_INFO_HEADERS to false as below.

    Map props = new HashMap<>(defaultSettings);
    props.put(JsonSerializer.ADD_TYPE_INFO_HEADERS, false);
    props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
    props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);
    ProducerFactory producerFactory = new DefaultKafkaProducerFactory<>(props);
    

    for your producer factory properties.

    In case you are using kafka version > 0.10.x.x, it should just work fine

提交回复
热议问题