Search code examples
spring-cloud-streamspring-cloud-stream-binder-kafka

Missing admin properties in KafkaBinderConfigurationProperties


The KafkaBinderConfigurationProperties class has dedicated properties for the producer and consumer. However, there is no admin properties.

While comparing with KafkaProperties which has the dedicated properties for producer, consumer and admin.

I would like to know are there specific reasons when designing KafkaBinderConfigurationProperties the admin properties were not considered.

So since I cannot configure specific admin properties using KafkaBinderConfigurationProperties, then other alternatives are using spring.cloud.stream.kafka.configuration.xxx or spring.kafka.admin.xxx.

Here are some short-comings of the above two alternatives I think,

  1. For using spring.cloud.stream.kafka.configuration.xxx, if I want to configure some properties only to admin, then I have to also set anther two properties of spring.cloud.stream.kafka.consumer-properties.xxx and spring.cloud.stream.kafka.producer-properties.xxx to override the admin value.
  2. For using spring.kafka.admin.xxx, it may cause some inconsistencies of my configurations. Since I am configuring the kafka producer, consumer and admin clients with different properties.

Solution

  • The binder will use the Boot spring.kafka.admin... properties first, then apply any binder properties.

    Finally, you can provide one or more AdminClientConfigCustomizer beans to perform further overrides.

    See https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/spring-cloud-stream-binder-kafka.html#admin-client-config-customization

    Customizing AdminClient Configuration

    As with consumer and producer config customization above, applications can also customize the configuration for admin clients by providing an AdminClientConfigCustomizer. AdminClientConfigCustomizer’s configure method provides access to the admin client properties, using which you can define further customization. Binder’s Kafka topic provisioner gives the highest precedence for the properties given through this customizer. ...