Reading messages from specific location

김소은·2026년 1월 27일

Reading messages from specific partition

특정 partition 안의 메시지만 읽어오는 명령어를 알아보자.

START CONSOLE CONSUMER AND READ MESSAGES FROM BEGINNING
FROM SPECIFIC PARTITION

bin/kafka-console-consumer.sh \
--bootstrap-server localhost:9092 \
--topic test \
--from-beginning \
--partition 2

위와같이 --partition 2 옵션을 설정하게 되면 partition 2에 있는 메시지만 읽어오게 된다.

Reading messages from specific offset in specific partition

bin/kafka-console-consumer.sh \
--bootstrap-server localhost:9092 \
--topic test \
--partition 2 --offset 2

최근 추가된 것부터 읽으려면 아래와 같이 입력한다.

bin/kafka-console-consumer.sh \
--bootstrap-server localhost:9092 \
--topic test \
--partition 2 --offset latest

Producer

Consumer

profile
개발자

0개의 댓글