카프카/Java 기반 카프카 클라이언트 구현, Consumer 내부 메커니즘 1

Consumer의 읽기 Commit 이해

webmaster 2025. 10. 6. 22:49
728x90

__consumer_offsets 토픽 읽기 실습하기

1. consumer.config 용 config 파일 생성

echo "exclude.internal.topics=false" > consumer_temp.config

2. __consumer_offsets 토픽 읽기

kafka-console-consumer --consumer.config /home/min/consumer_temp.config \
 --bootstrap-server localhost:9092 --topic __consumer_offsets \
 --formatter "kafka.coordinator.group.GroupMetadataManager\$OffsetsMessageFormatter"

3. topic 삭제 후 생성

kafka-topics --bootstrap-server localhost:9092 --delete --topic simple-topic
kafka-topics --bootstrap-server localhost:9092 --create --topic simple-topic

4. Producer 실행 후 메시지 전송

kafka-console-producer --bootstrap-server localhost:9092 --topic simple-topic
  • console producer를 실행해서 데이터를 전송 후, Application을 실행하면 offset이 전송한 데이터 수 + 1로 세팅되어 있다.

5. 결과 확인

728x90