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

Customize Instantiation of KafkaStreams in StreamsBuilderFactoryBean #3515

Closed
agavra opened this issue Sep 26, 2024 · 2 comments · Fixed by #3516
Closed

Customize Instantiation of KafkaStreams in StreamsBuilderFactoryBean #3515

agavra opened this issue Sep 26, 2024 · 2 comments · Fixed by #3516

Comments

@agavra
Copy link
Contributor

agavra commented Sep 26, 2024

Context

We'd like to be able to customize the construction of the KafkaStreams instance when using the StreamsBuilderFactoryBean in order to add native spring-kafka support for Responsive and other potential drop in replacements for Kafka Streams.

I am happy to contribute this change.

Proposed API

We will extend KafkaStreamsCustomizer to include an initialization method:

public interface KafkaStreamsCustomizer {

    // ...
    
    default KafkaStreams initializeKafkaStreams(Topology topology, Properties properties, KafkaClientSupplier supplier) {
        return new KafkaStreams(topology, properties, supplier);
    }

}

The StreamsBuilderFactoryBean will use this method when instantiating a new instance of KafkaStreams.

Example Usage

    @Bean
    public StreamsBuilderFactoryBeanConfigurer configurer() {
        return fb -> fb.setKafkaStreamsCustomizer(new KafkaStreamsCustomizer() {
           @Override KafkaStreams initializeKafkaStreams(Topology topology, Properties properties, KafkaClientSuppiler supplier) {
              // note that ResponsiveKafkaStreams extends KafkaStreams so this is a drop-in replacement
              return new ResponsiveKafkaStreams(topology, properties, supplier);
           }
        };
    }
@sobychacko
Copy link
Contributor

@agavra Sounds good. Feel free to contribute a PR. Then we can review it.

@agavra
Copy link
Contributor Author

agavra commented Sep 26, 2024

Thanks! #3516 PR is ready for review, since this is my first commit to spring-kafka please let me know if I'm missing anything 😄

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