I am using Long serializer for the keys and String serializer for value , after posting the message to the kafka topic when we retrieved the message and along with key are seeing key as some garbage value like below
^@^@^@^AÏÃ<9a>ò
is there anything wrong with kafka producer configuration ?
Update :
Below producer configuration
configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, LongSerializer.class.getName());
configProps.put(CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG, requestTimeoutInMillis);
configProps.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, abcompressionType);
@Bean
public ProducerFactory<Long, String> longProducerFactory() {
return new DefaultKafkaProducerFactory<>(longProducerConfigs());
}
@Bean
public KafkaTemplate<Long, String> longKeyKafkaTemplate() {
return new KafkaTemplate<>(longProducerFactory());
}
and below send call
longKeyKafkaTemplate.send(topicName, key, message);
LongDeserializer
there? – Gary Russell