kafka-console-producer와 kafka-console-consumer로 producer와 consumer 테스트
kafka-console-producer와 kafka-console-consumer
- bin/ 디렉토리에 kafka-console-producer, kafka-console-consumer 존재
- kafka-console-producer : 메시지 발행
- kafka-console-consumer : 메시지 소비
토픽 생성
kafka-topics --bootstrap-server localhost:9092 --create --topic test-topic
토픽 메시지 발행
kafka-console-producer --bootstrap-server localhost:9092 --topic test-topic
토픽 메시지 소비 (auto.offset.reset=latest)
kafka-console-consumer --bootstrap-server localhost:9092 --topic test-topic
토픽 메시지 소비 (auto.offset.reset=earliest)
kafka-console-consumer --bootstrap-server localhost:9092 --topic test-topic --from-beginning
Consumer의 auto.offset.reset이란?
- Consumer가 Topic에 처음 접속하여 Message를 가져올 때 가장 오래된 처음 offset부터(earliest) 가져올 것인지, 가장 최근인 마지막 offset부터(latest) 가져올 것인지를 설정하는 파라미터
- auto.offset.reset=earliest : 처음 offset부터 소비
- auto.offset.reset=latest : 마지막 offset부터 소비
- kafka-console-consumer 명령어 사용 시 --from-beginning 옵션을 사용해야 earliest로 지정된다.
'kafka > core' 카테고리의 다른 글
Consumer Group과 Consumer Rebalancing (0) | 2025.04.22 |
---|---|
Key가 없는 메시지의 파티션 분배 전략 - 라운드로빈과 스티키 파티셔닝 (0) | 2025.04.21 |
Producer의 객체 직렬화(Serializer) 전송의 이해 (0) | 2025.04.17 |
여러 개의 파티션을 가지는 메시지 전송 (0) | 2025.04.17 |
Key 값을 가지는 메시지 전송 (0) | 2025.04.16 |
댓글