Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin is boot up by turning on observability #2859

Closed
dogrizz opened this issue Oct 24, 2023 · 2 comments · Fixed by #2860
Closed

Admin is boot up by turning on observability #2859

dogrizz opened this issue Oct 24, 2023 · 2 comments · Fixed by #2860
Milestone

Comments

@dogrizz
Copy link

dogrizz commented Oct 24, 2023

In what version(s) of Spring for Apache Kafka are you seeing this issue?

3.0.10

Describe the bug

When enabling observabiity it tries to bring up AdminClient to retrieve clusterId even if adminClient auto-create is set to false.
When admin connection is blocked on other side it causes timeouts.
With default admin operation timeout message processing goes to a crawl as it tries to retrieve it on each message.

To Reproduce


    @Bean
    fun kafkaListenerContainerFactory(consumerFactory: ConsumerFactory<String?, String?>): ConcurrentKafkaListenerContainerFactory<String, String> {
        val factory = ConcurrentKafkaListenerContainerFactory<String, String>()
        factory.containerProperties.isObservationEnabled = true
        factory.consumerFactory = consumerFactory
        return factory
    }

Expected behavior

I would expect that when adminClient is disabled clusterId will be ignored or at least that we have a possibility to customize:
https://github.com/spring-projects/spring-kafka/blob/main/spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordReceiverContext.java
To not to try reading clusterId.

Sample

A link to a GitHub repository with a minimal, reproducible, sample.

Reports that include a sample will take priority over reports that do not.
At times, we may require a sample, so it is good to try and include a sample up front.

@garyrussell
Copy link
Contributor

I suppose we could add setClusterId to the KafkaAdmin which (when not null) would effectively disable the attempt to fetch the cluster id.

@garyrussell
Copy link
Contributor

In the meantime, you can subclass KafkaAdmin and override clusterId() to return some String.

factory.setContainerCustomizer(container -> {
	if (container.getListenerId().equals("obs3")) {
		((AbstractMessageListenerContainer<Integer, String>) container).setKafkaAdmin(myAdminNoClusterFetch);
	}
});

garyrussell added a commit to garyrussell/spring-kafka that referenced this issue Oct 25, 2023
artembilan pushed a commit that referenced this issue Oct 25, 2023
Resolves #2859

* Suppress fetching cluster id in `initialize()` if set manually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants