How to mutate ProducerRecord in ProducerInterceptor when used via KafkaTemplate? #2868
-
Suppose one has a var properties = HashMap<String, Object>();
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class.getName());
var producerFactory = new DefaultKafkaProducerFactory<>(properties);
var kafkaTemplate = new KafkaTemplate<>(producerFactory);
kafkaTemplate .setProducerInterceptor(myCustomInterceptor); According to the ProducerInterceptor.onSend documentation I can return a new mutated producer record, but I cannot get this to work. ProducerInterceptor.onSend(...)
To me it seems that the interceptor return value is not used at all. How is this supposed to be used? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
This is a bug; cc/ @sobychacko In the meantime, you can add the interceptor class name to the producer factory configuration properties instead of to the template. |
Beta Was this translation helpful? Give feedback.
-
Hi, @garyrussell |
Beta Was this translation helpful? Give feedback.
This is a bug; cc/ @sobychacko
In the meantime, you can add the interceptor class name to the producer factory configuration properties instead of to the template.