himanshug commented on a change in pull request #9573: Fix some flaws of
KafkaEmitter
URL: https://github.com/apache/druid/pull/9573#discussion_r405729389
##########
File path:
extensions-contrib/kafka-emitter/src/main/java/org/apache/druid/emitter/kafka/KafkaEmitter.java
##########
@@ -130,24 +120,24 @@ public void start()
private void sendMetricToKafka()
{
- sendToKafka(config.getMetricTopic(), metricQueue);
+ sendToKafka(config.getMetricTopic(), metricQueue,
setProducerCallback(metricLost));
}
private void sendAlertToKafka()
{
- sendToKafka(config.getAlertTopic(), alertQueue);
+ sendToKafka(config.getAlertTopic(), alertQueue,
setProducerCallback(alertLost));
}
- private void sendToKafka(final String topic,
MemoryBoundLinkedBlockingQueue<String> recordQueue)
+ private void sendToKafka(final String topic,
MemoryBoundLinkedBlockingQueue<String> recordQueue, Callback callback)
{
ObjectContainer<String> objectToSend;
try {
while (true) {
objectToSend = recordQueue.take();
- producer.send(new ProducerRecord<>(topic, objectToSend.getData()),
producerCallback);
+ producer.send(new ProducerRecord<>(topic, objectToSend.getData()),
callback);
}
}
- catch (InterruptedException e) {
+ catch (Throwable e) {
log.warn(e, "Failed to take record from queue!");
Review comment:
on any exception from the block inside `while(true) { ... }` would lead to
event emission getting stopped. Does it make sense to have a try-catch inside
there to ignore exceptions except for `InterruptedException` so that emitting
stops only on thread interrupt which would happen when druid is shutting down.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]