차이점이 뭐야? KafkaConsumer와 KafkaListener라는 용어를 같은 의미로 사용할 수 있습니까?
는 @KafkaListener
에 대한 높은 수준의 API입니다 ConcurrentMessageListenerContainer
주위에 여러 내부 청취자를 생성합니다, KafkaConsumer
.
차이점은 KafkaConsumer
API는 필요할 때 마다 호출 할 때 요청시 폴링poll()
할 수 있다는 것입니다. 리스너 추상화는 그 주위에 무한 루프를 갖기 직전 poll()
이며 poll()
. 다음과 같은 논리를 실행하는 작업 실행자가 있습니다.
while (isRunning()) {
try {
pollAndInvoke();
}
catch (@SuppressWarnings(UNUSED) WakeupException e) {
// Ignore, we're stopping
}
catch (NoOffsetForPartitionException nofpe) {
this.fatalError = true;
ListenerConsumer.this.logger.error("No offset and no reset policy", nofpe);
break;
}
catch (Exception e) {
handleConsumerException(e);
}
catch (Error e) { // NOSONAR - rethrown
Runnable runnable = KafkaMessageListenerContainer.this.emergencyStop;
if (runnable != null) {
runnable.run();
}
this.logger.error("Stopping container due to an Error", e);
wrapUp();
throw e;
}
}
는 KafkaConsumer.poll()
점에서라고합니다 pollAndInvoke();
.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다