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

Provide auto-configuration for Reactor Kafka #18751

Closed
jntakpe opened this issue Oct 25, 2019 · 11 comments
Closed

Provide auto-configuration for Reactor Kafka #18751

jntakpe opened this issue Oct 25, 2019 · 11 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@jntakpe
Copy link

jntakpe commented Oct 25, 2019

Spring Boot provides a great helper configuration KafkaProperties class for Kafka.

This class includes two spring-kafka module classes :

import org.springframework.kafka.listener.ContainerProperties.AckMode;
import org.springframework.kafka.security.jaas.KafkaJaasLoginModuleInitializer;

Due to those imports, in order to leverage Spring Boot's Kafka auto configuration, it is required to import spring-kafka module which is largely increasing the application size (our projects are using Reactor Kafka).

IMHO, the configuration that depends on spring-kafka should be moved to spring-kafka module, allowing Spring Boot's projects to leverage automatic type safe Kafka configuration without importing spring-kafka.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 25, 2019
@wilkinsona
Copy link
Member

Thanks for the suggestion. The whole auto-configuration, of which KafkaProperties is a part, depends on Spring for Apache Kafka. In other words, it's intentionally auto-configuration for Spring for Apache Kafka and not for Kafka itself. The auto-configuration will back off completely in the absence of Spring for Apache Kafka. Also, you shouldn't try to use KafkaProperties in your own code. As noted in the documentation, all configuration properties classes are for internal use only:

Similar to auto-configuration classes, @ConfigurationProperties classes available in Spring Boot are for internal use only. The properties that map to the class, which are configured via properties files, YAML files, environment variables etc., are public API but the content of the class itself is not meant to be used directly.

I don't think it makes sense for Spring Boot to offer configuration for Kafka without using Spring for Apache Kafka. Our opinion is that it makes sense to use the latter when interacting with Kafka in a Spring application. If you have use cases where that's not true, please share them here and we can reconsider or pass them on to the Spring for Apache Kafka team for them to look at.

@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 26, 2019
@jntakpe
Copy link
Author

jntakpe commented Oct 28, 2019

@wilkinsona, all our applications are microservices that relies on Spring Boot + Spring Webflux. All those microservices fully leverages Reactive programming so it was pretty obvious for us to connect to Kafka embracing reactive libraries. That's why we are using reactor-kafka to communicate with Kafka. Even if Spring-kafka supports some async types, IMHO it's not fully embracing reactive programming like reactor-kafka does. We are very pleased by all the effort made so for by Spring teams to push Java reactive support forward, it seems logical that Spring Boot enables easy Kafka configuration through KafkaProperties class letting users choose the fully reactive implementation reactor-kafka or the classic spring-kafka.

@wilkinsona
Copy link
Member

Thanks. So it sounds like what you're really looking for is auto-configuration support for Reactor Kafka. Can you share some details of how you're currently using Reactor Kafka and how you're using KafkaProperties to configure it?

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged and removed status: declined A suggestion or change that we don't feel we should currently apply labels Oct 28, 2019
@wilkinsona wilkinsona reopened this Oct 28, 2019
@jntakpe
Copy link
Author

jntakpe commented Oct 28, 2019

Actually that's pretty straightforward, we inject KafkaProperties to create both KafkaSender and KafkaReceiver beans. It looks like, the following sample :

@Bean
fun sender(properties: KafkaProperties): KafkaSender<String, String> {
     val options = SenderOptions.create<String, String>(properties.buildProducerProperties())
     return KafkaSender.create<String, String>(options)
}

Hence both KafkaSender and KafkaReceiver are configured using regular Spring properties.

The full reactor auto configuration support would be great. Nevertheless, being able to simply inject KafkaProperties without being forced to add spring-kafka to the classpath is our main concern

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 28, 2019
@wilkinsona
Copy link
Member

Thanks for the additional information.

Nevertheless, being able to simply inject KafkaProperties without being forced to add spring-kafka to the classpath is our main concern

This (alone) almost certainly won't happen. As I mentioned above, Boot's own @ConfigurationProperties classes should be considered internal so you should not be injecting KafkaProperties. Given that the only supported use of KafkaProperties is by the auto-configuration for Spring for Apache Kafka, and its needs are met by the current arrangement, it will be difficult to justify modifying KafkaProperties as you have described.

@jntakpe
Copy link
Author

jntakpe commented Oct 29, 2019

So you intent to provide a reactor-kafka auto configuration mechanism ?

@wilkinsona
Copy link
Member

wilkinsona commented Oct 29, 2019

We don't know yet, hence this issue still being labelled as waiting for triage. We can certainly consider it though. In the meantime, I would strongly encourage you to use your own configuration properties and @ConfigurationProperties class for the configuration of Reactor Kafka.

@jntakpe
Copy link
Author

jntakpe commented Oct 29, 2019

Yes that's what I intent to do. Thanks !

@wilkinsona wilkinsona changed the title Spring Boot KafkaProperties class should not rely on spring-kafka module Provide auto-configuration for Reactor Kafka Nov 4, 2019
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: feedback-provided Feedback has been provided labels Nov 4, 2019
@wilkinsona
Copy link
Member

Having discussed this with the Reactor team, we've decided not to add auto-configuration for Reactor Kafka at this time. If the situation changes, we can re-open this issue and reconsider. Thanks for the suggestion, @jntakpe.

@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 20, 2019
@matthewadams
Copy link

Understand the decision. Can you provide a quick tldr-style example here (or link thereto) that uses @ConfigurationProperties?

@wilkinsona
Copy link
Member

@matthewadams Unfortunately we don't have such an example to hand. The properties would really depend on your use case and the Reactor Kafka settings that you want to be able to configure using externalised properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants