无法更新元数据 - Cloudera Quickstart VM的Kafka Producer

时间:2018-04-06 04:01:51

标签: apache-kafka

我刚刚安装了Cloudera QuickStart VM并添加了Kafka服务。添加Kafka服务后,我可以轻松创建生产者/消费者,一切都按预期工作。几天后重新启动VM,我得到以下异常:

  

线程“main”中的异常java.util.concurrent.ExecutionException:org.apache.kafka.common.errors.TimeoutException:60000 ms后无法更新元数据。       在org.apache.kafka.clients.producer.KafkaProducer $ FutureFailure。(KafkaProducer.java:1124)       在org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:823)       在org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:760)       在org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:648)       at test.kafka.KafkaProducerExample.runProducer(KafkaProducerExample.java:37)       at test.kafka.KafkaProducerExample.main(KafkaProducerExample.java:54)   引起:org.apache.kafka.common.errors.TimeoutException:60000毫秒后无法更新元数据。

我尝试使用telnet连接到端口9092并且它可以工作。我可以从QuickStart VM内部发送消息。有什么建议吗?

2 个答案:

答案 0 :(得分:0)

您可以尝试删除zookeeper日志以及您的kafka经纪人日志,然后尝试运行您认为它会起作用。它不起作用,因为它正在获取旧日志。您可以从zookeeper.properties和server.properties更改日志目录路径。

答案 1 :(得分:-1)

val record = new ProducerRecord[String, String](settings.topic, notification.tableName, notification.toJson())
    producer.send(record).**get**
/**
     * Waits if necessary for at most the given time for the computation
     * to complete, and then retrieves its result, if available.
     *
     * @param timeout the maximum time to wait
     * @param unit the time unit of the timeout argument
     * @return the computed result
     * @throws CancellationException if the computation was cancelled
     * @throws ExecutionException if the computation threw an
     * exception
     * @throws InterruptedException if the current thread was interrupted
     * while waiting
     * @throws TimeoutException if the wait timed out
     */