Skip to content

Example in Producer/Consumer Interceptors section of Spring Framework documentation need to be fixed #3587

@jourteen

Description

@jourteen

Wiring Spring Beans into Producer/Consumer Interceptors section of Spring for Apache Kafka documentation contains following code snippet:

@Bean
public ProducerFactory<?, ?> kafkaProducerFactory(SomeBean someBean) {
    Map<String, Object> producerProperties = new HashMap<>();
    // producerProperties.put(..., ...)
    // ...
    Map<String, Object> producerProperties = properties.buildProducerProperties();
    producerProperties.put(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, MyProducerInterceptor.class.getName());
    producerProperties.put("some.bean", someBean);
    DefaultKafkaProducerFactory<?, ?> factory = new DefaultKafkaProducerFactory<>(producerProperties);
    return factory;
}

I understand this is just an example, but creating producerProperties twice is confusing. I suggest to completely remove the second instance to make kafkaProducerFactory look similar to kafkaConsumerFactory.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions