Skip to content

Commit

Permalink
fix: 한글 메시지 오류에 대한 KafkaProducerConfig부분 StringDeserializer로 추가 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kjungw1025 committed Jan 23, 2024
1 parent 83db056 commit 6b26153
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.dku.council.global.config.kafka;

import com.dku.council.domain.chat.model.dto.response.ResponseChatDto;
import lombok.RequiredArgsConstructor;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringSerializer;
Expand All @@ -11,7 +10,6 @@
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.core.ProducerFactory;
import org.springframework.kafka.support.serializer.JsonSerializer;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -25,12 +23,12 @@ public class KafkaProducerConfig {
private String bootstrapServers;

@Bean
public KafkaTemplate<String, ResponseChatDto> kafkaTemplate() {
public KafkaTemplate<String, String> kafkaTemplate() {
return new KafkaTemplate<>(producerFactory());
}

@Bean
public ProducerFactory<String, ResponseChatDto> producerFactory() {
public ProducerFactory<String, String> producerFactory() {
return new DefaultKafkaProducerFactory<>(producerConfig());
}

Expand All @@ -39,7 +37,7 @@ public Map<String, Object> producerConfig() {
Map<String, Object> props = new HashMap<>();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
return props;
}
}

0 comments on commit 6b26153

Please sign in to comment.