Kafka集群离线时,生产者应用程序崩溃

时间:2019-05-02 21:05:48

标签: apache-kafka kafka-producer-api

Kafka经纪人重新启动,结果生产者应用程序崩溃。消息以异步方式发送到kafka,这意味着如果kafka代理处于脱机状态,则生产者应用程序将不会有任何效果,因为将没有阻塞线程。我想了解为什么生产者应用程序崩溃了。有什么建议吗?

public void pushMessage(P partitionKey, M message, Consumer<Exception> exceptionHandler) {
   executorService.submit(() -> {
      // this.producer -> KafkaProducer<P, M> from the kafka lib
       producer.send(record, (metadata, exception) -> {
           if (exception != null && exceptionHandler != null) {
               exceptionHandler.accept(exception);
           }
       });
   });
}

0 个答案:

没有答案
相关问题