Tech_Forum
Tech_Forum

Reputation: 1

How to configure Spring Cloud Stream Kafka using pure java based configurations

Generally, we provide the Spring Cloud Stream Kafka configurations like the binder, consumer, producer configurations in application.yaml or application.properties.

I am looking for a way to configure it using pure JavaBean configuration.

I am specifically looking to Spring Cloud Stream Kafka configurations to Java based configurations like:

spring.cloud.stream.kafka.binder.configuration.security.protocol=SASL_SSL

Can someone provide a suggestion or offer a solution to this problem?

Upvotes: 0

Views: 396

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121560

One of the solution can be done via packaging an application.properties into a jar of your application. Another one can be done via an EnvironmentPostProcessor implementation.

And also you can create a BindingServiceProperties bean with the @Primary based on the BindingServiceProperties populated by the framework:

    @Bean
    @Primary
    public BindingServiceProperties bindingServiceProperties(
            BindingServiceProperties properties) {

And remap the properties you can provide in the external resource having the rest hard-coded here in this bean definition.

Upvotes: 1

Related Questions