Hi Luke, Yes our Admin creation was successful. Even though we have kept request.timeout.ms=100 there was no error or exception thrown. We used this admin to list out topics present in broker and it was successful. One thing I would like to point out is that we have created Admin not AdminClient. Will this be having any impact. Let us know about it. This is how we used it
try (Admin admin1 = Admin.create(properties)) { ListTopicsResult listTopicResult = admin1.listTopics(); KafkaFuture<Set<String>> kafkaFuture = listTopicResult.names(); try { if (kafkaFuture.get().contains(topicName)) { logger.debug("Required topic is present."); return true; } Thanks, Shruti -----Original Message----- From: Luke Chen <show...@gmail.com> Sent: Monday, December 12, 2022 3:09 PM To: dev@kafka.apache.org Cc: Brahmpal Kauntey <brahm.pal.si...@oracle.com> Subject: [External] : Re: Kafka AdminClient DEFAULT_API_TIMEOUT_MS_CONFIG property not working as expected Hi Shruti, Are you sure it creates admin client successfully after setting default.api.timeout.ms=2000 ? It should fail at this check: https://urldefense.com/v3/__https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java*L618-L621__;Iw!!ACWV5N9M2RV99hQ!IUZrOhRzkwvmXFTWD26OZXoyfDiz7B-fhT01GR-OHbz3oR9CRhisbAc5rq6RtORRbEzUuWonu1NrwvyYtQ$ Try also set request.timeout.ms=2000, please. Thank you. Luke On Mon, Dec 12, 2022 at 2:54 PM Shruti Pandey <shruti.pan...@oracle.com> wrote: > Hi, > > In my java application for kafkaProducer i created Admin and used this > to list topics. > > Admin admin1 = Admin.create(properties). > ListTopicsResult listTopicResult = admin1.listTopics(); > > When producer was not able to connect to broker, thread get stucks at > listTopic step. > > To avoid this i have added DEFAULT_API_TIMEOUT_MS_CONFIG property and > have set to 2000ms. so after 2s if producer is not able to connect to > broker timeout should happen. > properties.put(AdminClientConfig.DEFAULT_API_TIMEOUT_MS_CONFIG,2000). > But this does not work as expected. even DEFAULT_API_TIMEOUT_MS_CONFIG > with value 2000ms as property timeout didn't happen and thread was struck. > > Is there any other way to achieve timeout or do we need to configure > it in any other way? Also is using AdminClient instead of Admin can > have any impact. > > Thanks in advance > > Thanks > Shruti > >