Skip to content

Methods to build producer / consumer properties from KafkaProperties are inconvienenent to use without an SSL bundle #43300

@kitkars

Description

@kitkars

This request is related to 39144.

We used to have below methods in the KafkaProperties class.

buildProducerProperties()
buildConsumerProperties()

Looks like they have been removed / modified to accept SslBundles from 3.4.

buildProducerProperties(SslBundles sslBundles)
buildConsumerProperties(SslBundles sslBundles)

The Reactive Kafka Producer / Consumer Template classes have an option to accept the SenderOptions / ReceiverOptions as shown below. As the buildConsumerProperties requires SslBundles , I can pass null to make the code work as suggested in other thread.

    @Bean
    public ReceiverOptions<String,MyEvent> receiverOptions(KafkaProperties kafkaProperties){
        return ReceiverOptions.<String, MyEvent>create(kafkaProperties.buildConsumerProperties(null))
                .consumerProperty(JsonDeserializer.REMOVE_TYPE_INFO_HEADERS, "false")
                .consumerProperty(JsonDeserializer.USE_TYPE_INFO_HEADERS, false)
                .consumerProperty(JsonDeserializer.VALUE_DEFAULT_TYPE, MyEvent.class)
                .subscription(List.of("my-events"));
    }

    @Bean
    public ReactiveKafkaConsumerTemplate<String, MyEvent> consumerTemplate(ReceiverOptions<String, MyEvent> options){
        return new ReactiveKafkaConsumerTemplate<>(options);
    }

However, It is really convenient to have simple below overloaded method as part of the KafkaProperties class itself which calls the appropriate methods with null.

buildProducerProperties()
buildConsumerProperties()

It would be great if you consider this request.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions