에 생산 기록을 내가 예외 아래에 무엇입니까 동안 :카프카 : 예외 카프카의 주제에 대한 기록을 생산하면서 카프카 주제
java.lang.RuntimeException: This server is not the leader for that topic-partition.
아래는 카프카 주제에 레코드를 전송하는 코드입니다.
AtomicReference<Exception> exRef = new AtomicReference<>();
while([some condition]) {
producer.send(new ProducerRecord<>(topic, message), (metadata, exception) -> {
if (exception != null) {
exRef.set(exception);
}
});
if (exRef.get() != null) {
throw new RuntimeException(exRef.get().getMessage(), exRef.get().getCause());
}
}
이 예외가 발생하는 이유는 무엇입니까? 그것을 막는 방법?