kafka AdminClient API 超时等待节点分配
2022-09-04 04:42:19
我是Kafka的新手,正在尝试使用API来管理在我的本地计算机上运行的Kafka服务器。我的设置与Kafka文档的快速入门部分完全相同。唯一的区别是我没有创建任何主题。AdminClient
我在此设置上运行任何shell脚本都没有问题,但是当我尝试运行以下java代码时:
public class ProducerMain{
public static void main(String[] args) {
Properties props = new Properties();
props.setProperty(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG,
"localhost:9092");
try(final AdminClient adminClient =
KafkaAdminClient.create(props)){
try {
final NewTopic newTopic = new NewTopic("test", 1,
(short)1);
final CreateTopicsResult createTopicsResult =
adminClient.createTopics(
Collections.singleton(newTopic));
createTopicsResult.all().get();
}catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
}
}
错误:TimeoutException: Timed out waiting for a node assignment
Exception in thread "main" java.lang.RuntimeException: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment.
at ProducerMain.main(ProducerMain.java:41)
<br>Caused by: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment.
at org.apache.kafka.common.internals.KafkaFutureImpl.wrapAndThrow(KafkaFutureImpl.java:45)
at org.apache.kafka.common.internals.KafkaFutureImpl.access$000(KafkaFutureImpl.java:32)
at org.apache.kafka.common.internals.KafkaFutureImpl$SingleWaiter.await(KafkaFutureImpl.java:89)
at org.apache.kafka.common.internals.KafkaFutureImpl.get(KafkaFutureImpl.java:258)
at ProducerMain.main(ProducerMain.java:38)
<br>Caused by: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment.
我在网上搜索了有关问题可能是什么的迹象,但到目前为止还没有发现任何东西。欢迎任何建议,因为我处于绳索的尽头。