Kafka 컨슈머

Apache Kafka 입문

Mike Metzger

Data Engineering Consultant

컨슈머란?

  • Kafka 토픽에서 메시지를 읽음
    • 구독자라고도 불림
  • Kafka는 토픽에 저장된 메시지를 컨슈머에게 전달
  • 여러 컨슈머를 가질 수 있음
  • 하나 또는 여러 토픽에서 읽기 가능
Apache Kafka 입문

컨슈머 유형

  • 다양한 컨슈머 종류
    • 커맨드라인
      • kafka-console-consumer.sh
    • Python
    • Java
    • 기타 다양한 언어
    • Kafka Connect
Apache Kafka 입문

kafka-console-consumer.sh

  • 다른 Kafka 도구와 함께 bin/ 폴더에 위치
    • bin/kafka-console-consumer.sh
  • 여러 옵션 제공, 일부는 필수
  • kafka-console-producer와 동일한 필수 옵션:
    • --topic
    • --bootstrap-server
  • 기본적으로 메시지가 실시간으로 표시되는 연결을 열고 위치를 유지함
  • Ctrl-C로 종료
Apache Kafka 입문

선택적 인수

  • --from-beginning
    • 이미 읽은 메시지를 포함하여 토픽의 모든 메시지를 전송하도록 지정
  • --max-messages <number>
    • 최대 메시지 수만큼 읽은 후 종료
Apache Kafka 입문

대화형 예시

  • 대화형 예시
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 \
    --topic testing --from-beginning
This is the first message
This is the second message
This is the third message
<ctrl+c to exit>
Apache Kafka 입문

비대화형 예시

  • 비대화형
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 /
  --topic testing --from-beginning --max-messages 2
This is the first message
This is the second message
<automatically exits>
Apache Kafka 입문

연습해 봅시다!

Apache Kafka 입문

Preparing Video For Download...