inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

카프카 완벽 가이드 - 코어편

백그라운드 스레드 Sender에 대한 예외처리도 가능한가요?

해결된 질문

325

목동 개발자

작성한 질문수 35

0

KafkaProducer의 send 메소드를 try-catch 하면 아래와 같은 예외는 잡을 수 있는데요

 

Throws:

AuthenticationException – if authentication fails. See the exception for more details

AuthorizationException – fatal error indicating that the producer is not allowed to write

IllegalStateException – if a transactional.id has been configured and no transaction has been started, or when send is invoked after producer has been closed.

InterruptException – If the thread is interrupted while blocked

SerializationException – If the key or value are not valid objects given the configured serializers

TimeoutException – If the record could not be appended to the send buffer due to memory unavailable or missing metadata within max.block.ms.

KafkaException – If a Kafka related error occurs that does not belong to the public API exceptions.


Batch 로 레코드를 묶어서 실제로 브로커에게 전송하는 Sender Thread 에서 네트워크 이슈 등으로 실패하면 어떻게 처리해야할지가 궁금합니다.

(retries가 아닌 예외로 잡는 방법이 없을까요? ㅠㅠ)

kafka 데이터-엔지니어링

답변 1

0

권 철민

안녕하십니까,

네트웍 장애가 광범위해서 Exception을 특정할 수는 없지만, 보통은 네트웍 문제 시 TimeoutException이 발생합니다.

TimeoutException 설명은 아래와 같이 send buffer에 메모리가 더 이상 여유가 없어서 발생한다고 되어 있습니다.

imeoutException – If the record could not be appended to the send buffer due to memory unavailable or missing metadata within max.block.ms.

근데 주로 send buffer에 메모리가 가득 차는 이유는 Sender Thread가 네트웍이나 Kafka Broker가 Down되는 경우등으로 인해서 Kafka Broker로 메시지를 보내지 못하기 때문에 send buffer가 비워지지 않고 가득 차는 이유가 가장 큽니다.

때문에 네트웍에 문제가 생기면 주로 TimeoutException이 발생합니다.

 

감사합니다.

0

목동 개발자

Sender 구현체 코드를 분석하니 Producer Callback 을 통해서 예외를 핸들링 할 수 있네요

답변 감사합니다

virtual box 설치 문제

0

60

2

카프카 서버 구축 관련 문의

0

66

2

카프카 토픽 Key 타입 변경에 관한 질문

0

70

2

Zookeeper에서 KRaft

0

78

1

카프카 학습과 관련하여 질문 드립니다

0

96

2

파티션 증가시 비용 증가 고려

0

71

2

Kafka 초기 Partition 개수 설정 관련 질문

0

82

2

VM 과 도커의 차이

0

139

2

vm 어댑터설정 문의

0

78

2

Cooperative Sticky Rebalancing 질문

0

58

2

consumer 설정 질문

0

68

2

consumer.poll 질문입니다.

1

69

2

mainThread.join() 관련 질문

0

57

2

문의

0

153

2

멀티 브로커 설정 중 포트 충돌 발생

0

120

2

Consumer Group 강의 Lag 질문있습니다!

0

107

2

강의 설명 및 코드 정리

0

174

2

실습 코드는 어디서 받나요.. 아무리 찾아도 엄네요..

0

151

1

java.nio.BufferUnderflowException 에러 발생합니다..

0

156

3

KafkaTimeoutError:

0

157

2

acks 1 이면 비동기가 아니지 않나요?!

0

184

2

Producer의 메시지 비동기화 전송 구현 강좌 내용 중 질문

0

109

2

자문자답: 데이터 누락된다고 하시는 분 참고하세요.

0

215

2

자문자답: kafka Error connecting to node utuntu-20.myguest.virtualbox.org:9092

0

200

2