You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In what version(s) of Spring for Apache Kafka are you seeing this issue?
3.0.11
Describe the bug
If observation is enabled on a KafkaTemplate, whenever it produces a message, it tries to retrieve the cluster ID from the Kafka cluster.
Normally the cluster ID is retrieved once and then cached, but if the cluster does not have a cluster ID configured, the cached value remains null, and the request is made again on each next produce.
This is highly inefficient, because an AdminClient is created every time for this purpose.
See KafkaTemplate#clusterId(), which in turn calls KafkaAdmin#clusterId()
To Reproduce
Run a Kafka cluster without cluster ID configured
KafkaTemplate.setObservationEnabled(true)
Produce multiple messages
Observe the application logs: an AdminClient is being created for each produce attempt, and its config is printed
Expected behavior
KafkaTemplate can distinguish between the situations where it did not yet retrieve the cluster ID and when it is not configured on the cluster.