It appears that it isn't possible to specify a custom RecordMessageConverter for a producer. While you are able to set the message converter on the KafkaProducerMessageHandler's template, internally the handler constructs a ProducerRecord and then calls KafkaTemplate.send(ProducerRecord<K, V> record) which bypasses the template's message converter.
It appears that it isn't possible to specify a custom
RecordMessageConverter
for a producer. While you are able to set the message converter on theKafkaProducerMessageHandler
's template, internally the handler constructs aProducerRecord
and then callsKafkaTemplate.send(ProducerRecord<K, V> record)
which bypasses the template's message converter.See: https://github.com/spring-projects/spring-integration-kafka/blob/master/src/main/java/org/springframework/integration/kafka/outbound/KafkaProducerMessageHandler.java#L411
Original spring-cloud-stream issue: https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/790