Kafka Consumer 개요

group.id를 가지는 Consumer Group에 소속되어야함Consumer의 subscribe, poll, commit 로직

subscribe()를 호출하여 읽을 토픽을 등록poll() 메서드를 이용해 주기적으로 브로커의 토픽 파티션에서 메세지를 가져옴commit → __consumer_offset에 기록해서 다음에 읽을 offset 위치 참조Consumer의 주요 수행 개요
fetch ****및 poll 수행Rebalance를 수행 명령Consumer Client API 처리 로직

bootstrap.servers, key/value deserializer, group.id 등)subscribe() 를 통해 설정poll()을 호출하여 Topic의 메세지 읽음close()를 통해 객체 반환(중요)Consumer의 구성 요소와 poll() 메서드

Consumer 구성
poll(Duration.ofMillis(1000))
fetch를 브로커에 계속 수행하고 결과 반환poll() 메서드의 내부 동작

Consumer Fetcher 관련 Config

기본적으로 Fetcher는 Linked Queue에서 데이터를 가져오되, Linked Queue에 데이터가 없는 경우 ConsumerNetworkClient에서 데이터를 브로커로 부터 가져올 것을 요청
fetch.min.bytes
fetch.min.bytes 이상의 새로운 메세지가 쌓이기 전까지는 전송을 하지 않음default = 1fetch.max.wait.ms
fetch.min.bytes 이상의 메세지가 쌓일 때까지 최대 대기 시간default = 500msfetch.max.bytes
default = 500MBmax.partition.fetch.bytes
default = 1MBmax.poll.records
default = 500config 정리

Consumer의 auto.offset.reset
auto.offset.reset은 __consumer_offset의 정보가 없는 경우 어디부터 읽을지 설정하는 configealiest) 또는 가장 마지막부터(latest) 설정 가능