You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by "jan@zidek.eu" <ja...@gmail.com> on 2021/12/01 09:55:46 UTC

How to configure Spring Boot Kafka client so it does not try to connect

Could anyone answer my question here please?
https://stackoverflow.com/q/70182077/2886891

Thanks a lot,
Honza

Re: How to configure Spring Boot Kafka client so it does not try to connect

Posted by Luke Chen <sh...@gmail.com>.
Hi Honza,
> The problem is that the unsuccessful attempts to connect take about 30-40
seconds and our tests are significantly slowed down.
I think the reason why it retried for 30-40 seconds is that you tried to
create topics via adminClient (new KafkaAdmin.NewTopics) as described in
the Spring-Kafka KafkaAdmin javadoc here
<https://github.com/spring-projects/spring-kafka/blob/main/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaAdmin.java#L52-L53>.







*/*** An admin that delegates to an {@link AdminClient} to create topics
defined* in the application context....*/public class KafkaAdmin extends
KafkaResourceFactory ...*

And because the error `DisconnectException` is a retriable exception, Kafka
will keep retrying until `timeout`.

> Which of the configuration parameters or which combination of them
completely forbids the connection attempts, or at least forces the client
to try it only once?

I think it doesn't make sense when you want to use Kafka and create topics,
you forbid the connection attempts to brokers. But I think you can try to
reduce the retry/timeout value in adminClient. The config `retries` in
admin client config here
<https://kafka.apache.org/documentation/#adminclientconfigs_retries> might
be the one you're looking for. To set it to `0`, will not retry if
retriable error happened, or try to config the `request.timeout.ms` or `
default.api.timeout.ms` for timeout setting.

Hope that helps.

Thank you.
Luke


On Thu, Dec 2, 2021 at 1:32 AM Martin Gainty <mg...@hotmail.com> wrote:

> Honza
>
> did you try to set zookeeper.connection.timeout.ms.to 0 ?
>
> Apache Kafka<https://kafka.apache.org/documentation/#configuration>
> [http://apache-kafka.org/images/apache-kafka.png]<
> https://kafka.apache.org/documentation/#configuration>
> Apache Kafka<https://kafka.apache.org/documentation/#configuration>
> Apache Kafka: A Distributed Streaming Platform.
> kafka.apache.org
> ~martin~
>
> ________________________________
> From: jan@zidek.eu <ja...@gmail.com>
> Sent: Wednesday, December 1, 2021 4:55 AM
> To: users@kafka.apache.org <us...@kafka.apache.org>
> Subject: How to configure Spring Boot Kafka client so it does not try to
> connect
>
> Could anyone answer my question here please?
> https://stackoverflow.com/q/70182077/2886891
>
> Thanks a lot,
> Honza
>

Re: How to configure Spring Boot Kafka client so it does not try to connect

Posted by Martin Gainty <mg...@hotmail.com>.
Honza

did you try to set zookeeper.connection.timeout.ms.to 0 ?

Apache Kafka<https://kafka.apache.org/documentation/#configuration>
[http://apache-kafka.org/images/apache-kafka.png]<https://kafka.apache.org/documentation/#configuration>
Apache Kafka<https://kafka.apache.org/documentation/#configuration>
Apache Kafka: A Distributed Streaming Platform.
kafka.apache.org
~martin~

________________________________
From: jan@zidek.eu <ja...@gmail.com>
Sent: Wednesday, December 1, 2021 4:55 AM
To: users@kafka.apache.org <us...@kafka.apache.org>
Subject: How to configure Spring Boot Kafka client so it does not try to connect

Could anyone answer my question here please?
https://stackoverflow.com/q/70182077/2886891

Thanks a lot,
Honza