Customizing AdminClient Configuration

与上述消费者和生产者配置定制一样,应用程序还可以通过提供 AdminClientConfigCustomizer 来定制管理客户端的配置。AdminClientConfigCustomizer 的 configure 方法提供对管理客户端属性的访问,您可以使用它定义进一步的定制。Binder 的 Kafka 主题预配器为通过此定制器提供的属性提供最高优先级。以下是一个提供此定制器 bean 的示例。

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. Here is an example of providing this customizer bean.

@Bean
public AdminClientConfigCustomizer adminClientConfigCustomizer() {
    return props -> {
        props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SASL_SSL");
    };
}