Is there a way tp set the reconnect frequency or time between two reconnect tries in spring cloud stream kafka binder?
In case the kafka cluster goes down while the application is running, it continuously tries to reconnect and the CPU usage goes up to 100%.
I can see a property recoveryInterval
in KafkaConsumerProperties.java (part of spring-cloud-stream-binder-kafka-core-3.0.6.RELEASE), but the comments say that it is deprecated, and not used by the binder. Is there an alternative property I can use?
EDIT: Here's how I'm setting the property (acc to this):
# in application.properties
spring.cloud.stream.kafka.streams.binder.configuration.reconnect.backoff.ms=5000
spring.cloud.stream.kafka.streams.binder.configuration.reconnect.backoff.max.ms=10000
I also tried setting it directly, but that didn't work too.
reconnect.backoff.ms=5000
reconnect.backoff.max.ms=10000
EDIT 2:
Setting it this way works. But the CPU usage still goes up to 100%.
# in application.properties
spring.cloud.stream.kafka.binder.configuration.reconnect.backoff.ms=5000
spring.cloud.stream.kafka.binder.configuration.reconnect.backoff.max.ms=10000
See https://kafka.apache.org/documentation/#streamsconfigs_reconnect.backoff.ms
The base amount of time to wait before attempting to reconnect to a given host. This avoids repeatedly connecting to a host in a tight loop. This backoff applies to all connection attempts by the client to a broker.
and
https://kafka.apache.org/documentation/#streamsconfigs_reconnect.backoff.max.ms
The maximum amount of time in milliseconds to wait when reconnecting to a broker that has repeatedly failed to connect. If provided, the backoff per host will increase exponentially for each consecutive connection failure, up to this maximum. After calculating the backoff increase, 20% random jitter is added to avoid connection storms.