Kafka消费者在提交补偿和重新平衡方面失败

wko9yo5t  于 2021-06-08  发布在  Kafka
关注(0)|答案(0)|浏览(331)

我有一个Kafka消费者,它只订阅了一个主题。在某个时间点,在正常工作后,我在日志中收到以下消息:

Line 25694: 2017-05-15 17:59:53.656 [INFO ] [MeasureConsumerExecutor] AbstractCoordinator - Attempt to heart beat failed since the group is rebalancing, try to re-join group.
Line 25739: 2017-05-15 18:01:39.745 [INFO ] [MeasureConsumerExecutor] AbstractCoordinator - Marking the coordinator 2147483647 dead.
Line 25740: 2017-05-15 18:01:39.745 [WARN ] [MeasureConsumerExecutor] ConsumerCoordinator - Auto offset commit failed: null
Line 25766: 2017-05-15 18:10:52.539 [INFO ] [MeasureConsumerExecutor] AbstractCoordinator - Marking the coordinator 2147483647 dead.
Line 25789: 2017-05-15 18:25:51.036 [INFO ] [MeasureConsumerExecutor] AbstractCoordinator - Marking the coordinator 2147483647 dead.
Line 25790: 2017-05-15 18:25:52.241 [WARN ] [MeasureConsumerExecutor] ConsumerCoordinator - Auto offset commit failed: null
Line 25796: 2017-05-15 18:31:10.354 [INFO ] [MeasureConsumerExecutor] AbstractCoordinator - Marking the coordinator 2147483647 dead.
Line 25797: 2017-05-15 18:31:24.101 [INFO ] [MeasureConsumerExecutor] EventConsumer - run() - WARN - msg: KafkaConsumer will be CLOSED!

我的代码非常简单:

private final AtomicBoolean closed = new AtomicBoolean(false); ...
...
...
try {   
        while (!closed.get()) {
            ConsumerRecords<String, Message> records = kafkaConsumer.poll(Long.MAX_VALUE);
            for (ConsumerRecord<String, Message> record : records) {
                Message message = record.value();
                messageArrived(message);
            }
        }
        logger.info("run() - NOTIFY - msg: idConsumer = [{}] HAS !closed.get() = [{}]", consumerId, !closed.get());
    } catch (WakeupException wakeupException) {
        logger.error("run() - ERROR - msg: Error on Consumer [{}] caused by = [{}]", getConsumerId(), wakeupException.getMessage(), wakeupException);
        // Ignore exception if closing 
        if (!closed.get()) 
            throw wakeupException;
    } catch (KafkaException kafkaException) {
        logger.error("run() - ERROR - msg: Error on Consumer [" + getConsumerId() + "] caused by = [" + kafkaException.getMessage() + "]", kafkaException);
    } catch (Exception exception) {
        logger.error("run() - ERROR - msg: Error on Consumer [" + getConsumerId() + "] caused by = [" + exception.getMessage() + "]", exception);
    } finally {
        logger.info("run() - WARN - msg: KafkaConsumer will be CLOSED!");
        if (null != kafkaConsumer) {
            kafkaConsumer.close();
        }
    }
}

奇怪的是,我得到了最后一个警告日志(“kafkaconsumer will be closed”),而没有进入异常日志(因此显然没有异常),而且“closed”变量没有任何更改。
我有多个类似这样的消费者在不同的主题上并行运行,但我认为这是不相关的。代理位于同一子网中的不同物理计算机上。
你能给我一些关于这里发生的事情的提示吗?我如何处理这个问题以防止消费者断开连接或者至少能够从中恢复?
非常感谢。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题