Why Kafka Producer Publishing String Message with Double Quotes in Spring Boot

Viewed 1115

I am trying to publish String Message into Kafka Topic in Spring Boot.

I want to publish message without double quotes in Kafka topic like as shown below:

IN|TN|2021-03-03 15:22:04.000400|2021-03-03T15:22:09.370002|00000002810000149059|1|8888888888

but it is publishing in Kafka topic with double quotes like as shown below:

"IN|TN|2021-03-03 15:22:04.000400|2021-03-03T15:22:09.370002|00000002810000149059|1|8888888888"

and using producer.key-serializer is StringDeserializer and producer.value-serializer is JsonSerializer and also tried value-serializer with StringSerializer even issue is still persists.

Code as below:

@Autowired
private KafkaTemplate<String, String> kafkaTemplate;

Message<String> message = MessageBuilder.withPayload(msg).setHeader(KafkaHeaders.TOPIC, this.topicSender)
                .build();

kafkaTemplate.send(message);

Can anyone please help me here that to publish string message without quotes in Kafka topic.

1 Answers

Configure the producer value serializer as StringSerializer

spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
Related