๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์Šคํ”„๋ง ๋ถ€ํŠธ์—์„œ Kafka ์„ค์ •ํ•˜๊ธฐ: ๊ฐ„๋‹จํ•˜๊ณ  ๋น ๋ฅด๊ฒŒ ๋ฐฐ์šฐ๋Š” ๋ฐฉ๋ฒ•

okrestart 2024. 10. 22.

 

์Šคํ”„๋ง ๋ถ€ํŠธ ์™€ Apache Kafka ๋ฅผ ํ†ตํ•ฉํ•˜์—ฌ ์‹ค์‹œ๊ฐ„ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋งŽ์€ ๊ธฐ์—…๊ณผ ๊ฐœ๋ฐœ์ž๋“ค์ด ํ™œ์šฉํ•˜๋Š” ์ค‘์š”ํ•œ ๊ธฐ์ˆ ์ž…๋‹ˆ๋‹ค. ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” application.yml ๋˜๋Š” application.properties ํŒŒ์ผ์„ ์‚ฌ์šฉํ•œ Kafka ์„ค์ • ๋ฐฉ๋ฒ•, ํ”„๋กœ๋“€์„œ์™€ ์ปจ์Šˆ๋จธ ์„ค์ •, ๊ธฐ๋ณธ ์ง๋ ฌํ™”๊ธฐ/์—ญ์ง๋ ฌํ™”๊ธฐ ์„ค์ •, ๊ทธ๋ฆฌ๊ณ  ์‚ฌ์šฉ์ž ์ •์˜ Kafka ์†์„ฑ์„ ์ ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ๊ณผ์ •์€ ์ฝ”๋“œ ์˜ˆ์ œ์™€ ํ•จ๊ป˜ ์ œ๊ณต๋˜์–ด ์‰ฝ๊ฒŒ ๋”ฐ๋ผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 


 

 

1. application.properties ๋˜๋Š” application.yml ์„ค์ • ํŒŒ์ผ ์ดํ•ดํ•˜๊ธฐ

 

application.yml ์„ ํ†ตํ•œ Kafka ์„ค์ •

์Šคํ”„๋ง ๋ถ€ํŠธ์—์„œ Kafka๋ฅผ ์„ค์ •ํ•˜๋ ค๋ฉด application.yml ๋˜๋Š” application.properties ํŒŒ์ผ์— ์„ค์ •์„ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” YAML ํ˜•์‹์„ ์‚ฌ์šฉํ•œ ์„ค์ • ์˜ˆ์ œ๋ฅผ ๋ณด์—ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

spring:
  kafka:
    bootstrap-servers: localhost:9092
    consumer:
      group-id: my-group
      auto-offset-reset: earliest
    producer:
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.apache.kafka.common.serialization.StringSerializer

 

์ฃผ์š” ์„ค์ • ํ•ญ๋ชฉ:

  • bootstrap-servers : Kafka ๋ธŒ๋กœ์ปค์˜ ์ฃผ์†Œ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
  • group-id : ์ปจ์Šˆ๋จธ ๊ทธ๋ฃน์˜ ID๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
  • auto-offset-reset : ์ƒˆ๋กœ์šด ์ปจ์Šˆ๋จธ๊ฐ€ ์‹œ์ž‘ํ•  ๋•Œ ์˜คํ”„์…‹์„ ์–ด๋””์„œ๋ถ€ํ„ฐ ์ฝ์„์ง€ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. earliest ๋กœ ์„ค์ •ํ•˜๋ฉด ๊ฐ€์žฅ ์ฒ˜์Œ๋ถ€ํ„ฐ ์ฝ๊ธฐ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.
  • key-serializer / value-serializer : Kafka ๋ฉ”์‹œ์ง€์˜ ํ‚ค์™€ ๊ฐ’์„ ์ง๋ ฌํ™”ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ String ํƒ€์ž…์œผ๋กœ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

application.properties ์„ค์ • ์˜ˆ์‹œ

application.properties ํ˜•์‹์„ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ, ๋™์ผํ•œ ์„ค์ •์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

spring.kafka.bootstrap-servers=localhost:9092
spring.kafka.consumer.group-id=my-group
spring.kafka.consumer.auto-offset-reset=earliest
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer

 


 

2. Kafka ํ”„๋กœ๋“€์„œ์™€ ์ปจ์Šˆ๋จธ ์„ค์ • ๋ฐฉ๋ฒ•

 

Kafka ํ”„๋กœ๋“€์„œ ์„ค์ •

Kafka ํ”„๋กœ๋“€์„œ๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ๋ธŒ๋กœ์ปค์— ์ „์†ก ํ•˜๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค. ์Šคํ”„๋ง ๋ถ€ํŠธ ์—์„œ๋Š” KafkaTemplate์„ ์‚ฌ์šฉํ•˜์—ฌ ์‰ฝ๊ฒŒ ๋ฉ”์‹œ์ง€๋ฅผ ์ „์†กํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

@Service
public class KafkaProducer {
    private static final Logger logger = LoggerFactory.getLogger(KafkaProducer.class);
    private final KafkaTemplate<String, String> kafkaTemplate;

    @Autowired
    public KafkaProducer(KafkaTemplate<String, String> kafkaTemplate) {
        this.kafkaTemplate = kafkaTemplate;
    }

    public void sendMessage(String message) {
        logger.info(String.format("#### -> Producing message -> %s", message));
        this.kafkaTemplate.send("my_topic", message);
    }
}

 

์„ค๋ช…:

  • KafkaTemplate ์„ ํ†ตํ•ด ๋ฉ”์‹œ์ง€๋ฅผ ์ „์†กํ•ฉ๋‹ˆ๋‹ค.
  • send ๋ฉ”์„œ๋“œ๋Š” ์ง€์ •ํ•œ ํ† ํ”ฝ (์—ฌ๊ธฐ์„œ๋Š” my_topic )์— ๋ฉ”์‹œ์ง€๋ฅผ ์ „์†กํ•ฉ๋‹ˆ๋‹ค.

Kafka ์ปจ์Šˆ๋จธ ์„ค์ •

Kafka ์ปจ์Šˆ๋จธ๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ์†Œ๋น„ ํ•˜๋Š” ์—ญํ• ์„ ํ•˜๋ฉฐ, ์ฃผ๋กœ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ๋‚˜ ์‹ค์‹œ๊ฐ„ ๋ถ„์„์— ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์Šคํ”„๋ง ๋ถ€ํŠธ์—์„œ๋Š” @KafkaListener ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฉ”์‹œ์ง€๋ฅผ ์ˆ˜์‹ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

@Service
public class KafkaConsumer {
    private static final Logger logger = LoggerFactory.getLogger(KafkaConsumer.class);

    @KafkaListener(topics = "my_topic", groupId = "my-group")
    public void consume(String message) {
        logger.info(String.format("#### -> Consumed message -> %s", message));
    }
}

 

์„ค๋ช…:

  • @KafkaListener ๋ฅผ ํ†ตํ•ด ์ง€์ •๋œ ํ† ํ”ฝ( my_topic )์—์„œ ๋ฉ”์‹œ์ง€๋ฅผ ์ˆ˜์‹ ํ•ฉ๋‹ˆ๋‹ค.
  • ์ˆ˜์‹ ๋œ ๋ฉ”์‹œ์ง€๋Š” consume ๋ฉ”์„œ๋“œ์—์„œ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

 


 

3. ๊ธฐ๋ณธ ์ง๋ ฌํ™”๊ธฐ์™€ ์—ญ์ง๋ ฌํ™”๊ธฐ ์„ค์ •

Kafka๋Š” ์ง๋ ฌํ™” ์™€ ์—ญ์ง๋ ฌํ™” ๋ฅผ ํ†ตํ•ด ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐ”์ดํŠธ ์ŠคํŠธ๋ฆผ ์œผ๋กœ ๋ณ€ํ™˜ํ•˜๊ณ , ๋‹ค์‹œ ๊ฐ์ฒด๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ณผ์ •์„ ๊ฑฐ์นฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ๋Š” String ์„ ์ง๋ ฌํ™”ํ•˜์ง€๋งŒ, ํ•„์š”์— ๋”ฐ๋ผ ์ปค์Šคํ…€ ์ง๋ ฌํ™”๊ธฐ๋ฅผ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ธฐ๋ณธ ์ง๋ ฌํ™”๊ธฐ ์„ค์ •

Kafka์—์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” StringSerializer ์™€ StringDeserializer ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ฌธ์ž์—ด ๋ฐ์ดํ„ฐ๋ฅผ ์‰ฝ๊ฒŒ ์ „์†กํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์•ž์„œ ์‚ดํŽด๋ณธ application.yml ์„ค์ •์—์„œ ์ด๋ฏธ ์ ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค:

spring:
  kafka:
    producer:
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.apache.kafka.common.serialization.StringSerializer
    consumer:
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer

JSON ์ง๋ ฌํ™”/์—ญ์ง๋ ฌํ™” ์„ค์ •

๋งŒ์•ฝ JSON ํ˜•์‹ ์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ ๋ฐ›๊ณ  ์‹ถ๋‹ค๋ฉด, Jackson ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ง๋ ฌํ™”๊ธฐ์™€ ์—ญ์ง๋ ฌํ™”๊ธฐ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

spring:
  kafka:
    producer:
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
    consumer:
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
    consumer-properties:
      spring.json.trusted.packages: "*"

์ด ์„ค์ •์„ ํ†ตํ•ด ํ”„๋กœ๋“€์„œ๊ฐ€ JSON ๋ฐ์ดํ„ฐ ๋ฅผ ์ง๋ ฌํ™”ํ•˜๊ณ , ์ปจ์Šˆ๋จธ๊ฐ€ ์ด๋ฅผ ์—ญ์ง๋ ฌํ™”ํ•˜์—ฌ Java ๊ฐ์ฒด ๋กœ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 


 

4. ์‚ฌ์šฉ์ž ์ •์˜ Kafka ์†์„ฑ ์ ์šฉ

Kafka์˜ ๊ธฐ๋ณธ ์„ค์ • ์™ธ์—๋„ ํ•„์š”์— ๋”ฐ๋ผ ์‚ฌ์šฉ์ž ์ •์˜ ์†์„ฑ ์„ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ACK(ํ™•์ธ ์‘๋‹ต) ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ์‚ฌ์šฉ์ž ์ •์˜ํ•˜์—ฌ ๋ฐ์ดํ„ฐ ์†์‹ค์„ ์ตœ์†Œํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ACK ๋ฉ”์ปค๋‹ˆ์ฆ˜ ์„ค์ •

ACK ์„ค์ •์€ ํ”„๋กœ๋“€์„œ๊ฐ€ ๋ฉ”์‹œ์ง€๋ฅผ ์ „์†กํ•œ ํ›„ Kafka ๋ธŒ๋กœ์ปค๋กœ๋ถ€ํ„ฐ ํ™•์ธ ์‘๋‹ต ์„ ๋ฐ›์„ ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆฌ๋Š” ๋ฐฉ์‹์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ๋ฉ”์‹œ์ง€ ์ „๋‹ฌ์˜ ์•ˆ์ •์„ฑ์„ ๋ณด์žฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

spring:
  kafka:
    producer:
      acks: all  # ๋ชจ๋“  ๋ธŒ๋กœ์ปค์—์„œ ์‘๋‹ต์„ ๋ฐ›์•˜์„ ๋•Œ๋งŒ ์„ฑ๊ณต์œผ๋กœ ์ฒ˜๋ฆฌ
      retries: 3  # ๋ฉ”์‹œ์ง€ ์ „์†ก ์‹คํŒจ ์‹œ ์žฌ์‹œ๋„ ํšŸ์ˆ˜
  • acks: all : ๋ชจ๋“  ๋ฆฌํ”Œ๋ฆฌ์นด์—์„œ ๋ฉ”์‹œ์ง€๊ฐ€ ๊ธฐ๋ก๋˜์—ˆ์„ ๋•Œ๋งŒ ์„ฑ๊ณต์œผ๋กœ ๊ฐ„์ฃผํ•ฉ๋‹ˆ๋‹ค.
  • retries: 3 : ์ „์†ก ์‹คํŒจ ์‹œ ์ตœ๋Œ€ 3๋ฒˆ๊นŒ์ง€ ์žฌ์‹œ๋„ํ•ฉ๋‹ˆ๋‹ค.

๋ฐฐ์น˜ ์ฒ˜๋ฆฌ ์„ค์ •

Kafka์—์„œ ๋ฐฐ์น˜ ์ฒ˜๋ฆฌ ๋ฅผ ํ™œ์„ฑํ™”ํ•˜๋ฉด, ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ฉ”์‹œ์ง€๋ฅผ ๋ชจ์•„์„œ ํ•œ ๋ฒˆ์— ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์–ด ์„ฑ๋Šฅ์ด ํ–ฅ์ƒ๋ฉ๋‹ˆ๋‹ค.

spring:
  kafka:
    consumer:
      enable-auto-commit: false  # ์ž๋™ ์ปค๋ฐ‹ ๋น„ํ™œ์„ฑํ™”
      max-poll-records: 10  # ํ•œ ๋ฒˆ์— ์ตœ๋Œ€ 10๊ฐœ์˜ ๋ฉ”์‹œ์ง€ ์ฒ˜๋ฆฌ

์ด ์„ค์ •์„ ํ†ตํ•ด ํ•œ ๋ฒˆ์— ์—ฌ๋Ÿฌ ๋ฉ”์‹œ์ง€๋ฅผ ์ฝ๊ณ  ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฐ์น˜ ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•ด์ง‘๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ์ฒ˜๋ฆฌ ์†๋„๋ฅผ ๋†’์ด๊ณ , ๋ฆฌ์†Œ์Šค ์‚ฌ์šฉ์„ ์ตœ์ ํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 


 

์Šคํ”„๋ง ๋ถ€ํŠธ์—์„œ Kafka ์„ค์ • ํŠธ๋ Œ๋“œ ๋ฐ ํ†ต๊ณ„

Kafka๋Š” ์ „ ์„ธ๊ณ„์ ์œผ๋กœ ๋Œ€๊ทœ๋ชจ ์‹ค์‹œ๊ฐ„ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ๋ฅผ ์œ„ํ•œ ํ•„์ˆ˜ ๋„๊ตฌ๋กœ ์ž๋ฆฌ ์žก๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ตœ๊ทผ 2023๋…„ Stack Overflow ๊ฐœ๋ฐœ์ž ์„ค๋ฌธ์กฐ์‚ฌ ์— ๋”ฐ๋ฅด๋ฉด, ๋งŽ์€ ๊ฐœ๋ฐœ์ž๋“ค์ด Kafka๋ฅผ ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค ์•„ํ‚คํ…์ฒ˜์—์„œ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์œผ๋ฉฐ, Kafka๋ฅผ ์‚ฌ์šฉํ•œ ๊ธฐ์—… ์ค‘ 80% ์ด์ƒ์ด ๋ฐ์ดํ„ฐ ์†์‹ค ์—†์ด ์‹ค์‹œ๊ฐ„ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ๋ฅผ ์„ฑ๊ณต์ ์œผ๋กœ ๊ตฌํ˜„ํ–ˆ๋‹ค๊ณ  ๋ณด๊ณ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

 


 

์ž์ฃผ ๋ฌป๋Š” ์งˆ๋ฌธ (FAQ)

Q1. Kafka ์„ค์ • ํŒŒ์ผ์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ํ•ญ๋ชฉ์€ ๋ฌด์—‡์ธ๊ฐ€์š”?
A1. bootstrap-servers , group-id , key/value ์ง๋ ฌํ™”๊ธฐ ์„ค์ •์ด ๊ฐ€์žฅ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด ์„ค์ •๋“ค์ด Kafka์™€ ๋ธŒ๋กœ์ปค๋ฅผ ์—ฐ๊ฒฐํ•˜๊ณ , ๋ฐ์ดํ„ฐ๋ฅผ ์ง๋ ฌํ™”/์—ญ์ง๋ ฌํ™”ํ•˜๋Š” ๊ณผ์ •์„ ์ œ์–ดํ•ฉ๋‹ˆ๋‹ค.

Q2. Kafka ํ”„๋กœ๋“€์„œ์™€ ์ปจ์Šˆ๋จธ๋ฅผ ๋™์‹œ์— ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‚˜์š”?
A2. ๋„ค, ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์Šคํ”„๋ง ๋ถ€ํŠธ์—์„œ๋Š” ๋™์ผํ•œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ Kafka ํ”„๋กœ๋“€์„œ์™€ ์ปจ์Šˆ๋จธ๋ฅผ ๋™์‹œ์— ์„ค์ •ํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Q3. ๋ฐฐ์น˜ ์ฒ˜๋ฆฌ๋Š” ์–ด๋–ค ์ƒํ™ฉ์—์„œ ์œ ๋ฆฌํ•œ๊ฐ€์š”?
A3. ๋ฐฐ์น˜ ์ฒ˜๋ฆฌ ๋Š” ๋งŽ์€ ์–‘์˜ ๋ฉ”์‹œ์ง€๋ฅผ ํ•œ ๋ฒˆ์— ์ฒ˜๋ฆฌํ•ด์•ผ ํ•  ๋•Œ ์œ ๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ๋ฐฐ์น˜ ์ฒ˜๋ฆฌ๋กœ ์„ฑ๋Šฅ์„ ์ตœ์ ํ™”ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์‹œ์Šคํ…œ ๋ฆฌ์†Œ์Šค๋ฅผ ์ ˆ์•ฝํ•˜๊ณ  ์ฒ˜๋ฆฌ ์†๋„๋ฅผ ๋†’์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ๋กœ ๋กœ๊ทธ ์ˆ˜์ง‘ , ํŠธ๋žœ์žญ์…˜ ์ฒ˜๋ฆฌ ์™€ ๊ฐ™์€ ๋Œ€๋Ÿ‰ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ์—์„œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

Q4. Kafka ์ง๋ ฌํ™”๊ธฐ๋ฅผ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•ํ•  ์ˆ˜ ์žˆ๋‚˜์š”?
A4. ๋„ค, ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. Kafka๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ StringSerializer ๋ฅผ ์ œ๊ณตํ•˜์ง€๋งŒ, ํ•„์š”์— ๋”ฐ๋ผ JsonSerializer ๋˜๋Š” ์ง์ ‘ ๋งŒ๋“  ์ปค์Šคํ…€ ์ง๋ ฌํ™”๊ธฐ ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์›ํ•˜๋Š” ํ˜•์‹์œผ๋กœ ์ง๋ ฌํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Q5. Kafka์˜ ACK ๋ฉ”์ปค๋‹ˆ์ฆ˜์ด ์ค‘์š”ํ•œ ์ด์œ ๋Š” ๋ฌด์—‡์ธ๊ฐ€์š”?
A5. ACK ๋ฉ”์ปค๋‹ˆ์ฆ˜ ์€ ๋ฉ”์‹œ์ง€๊ฐ€ ์•ˆ์ „ํ•˜๊ฒŒ ์ „๋‹ฌ๋˜์—ˆ๋Š”์ง€๋ฅผ ํ™•์ธํ•˜๋Š” ๊ณผ์ •์ž…๋‹ˆ๋‹ค. ๋ฉ”์‹œ์ง€ ์†์‹ค์„ ๋ฐฉ์ง€ํ•˜๊ณ , ์•ˆ์ •์ ์ธ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด ํ”„๋กœ๋“€์„œ๊ฐ€ ๋ธŒ๋กœ์ปค๋กœ๋ถ€ํ„ฐ ํ™•์ธ ์‘๋‹ต์„ ๋ฐ›๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. ACK๋ฅผ all ๋กœ ์„ค์ •ํ•˜๋ฉด ๋ชจ๋“  ๋ธŒ๋กœ์ปค์—์„œ ๋ฉ”์‹œ์ง€๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ์ €์žฅ๋˜์—ˆ์„ ๋•Œ๋งŒ ์„ฑ๊ณต์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๋ฏ€๋กœ ์•ˆ์ •์„ฑ์„ ๋†’์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋Œ“๊ธ€