How to display topics using Kafka Clients in Java?

筅森魡賤 提交于 2021-02-20 04:55:27

问题


public static void main(String [] args){

Properties config = new Properties();

config.put(AdminClientConfig.BOOTSRAP._SERVERS_CONFIG, "mybroker.ip.address:9092");

AdminClient admin = AdminClient.create(config);
ListTopicsResult ltr = admin.listTopics().names().get();

}

I am catching an ExecutionException with the error messages: org.apache.kafka.common.errors.TimeoutException: Call(callName:listTopics, deadlineMs=1599813311360, tries=1, nextAllowedTryMs=-9223372034707292162) timed out at 9223372036854775807 after 1 attempt(s)

StackTrace points to the class KafkaFutureImpl in wrapAndThrow.

I can't really paste the entire error since I am writing all of this through my mobile phone.

I am using Kafka Clients 2.6.0, JDK 1.8.0_191

this is very weird since the timeout happens instantly, and I have also tried passing arguments into get(time, timeunit) and I am getting the same result.

EDIT: I was missing some dependencies in the POM. That resolved the issue.

来源:https://stackoverflow.com/questions/63450560/how-to-display-topics-using-kafka-clients-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!