[英]Java Kafka Client Dynamic Sasl Jaas config update
Is there way to dynamically update Java client Kafka producers sasl jaas config without stopping/recreating client each time of Jaas config update?有没有办法动态更新 Java 客户端 Kafka 生产者 sasl jaas 配置,而无需在每次 Jaas 配置更新时停止/重新创建客户端?
Generally, Jaas config has a template that looks like org.apache.kafka.common.security.scram.ScramLoginModule required username="%s" password="%s";
一般来说,Jaas 配置有一个看起来像org.apache.kafka.common.security.scram.ScramLoginModule required username="%s" password="%s";
的模板。 , which is used for authentication. ,用于身份验证。 If, for example, Kafka cluster administrator change password of the user it won't be disconnected automatically, after some time you'll get an error and session will be terminated.例如,如果Kafka集群管理员更改用户的密码,它不会自动断开连接,一段时间后你会得到一个错误,session将被终止。 You can something like你可以像
try{
final Consumer<Long, String> consumer = new KafkaConsumer<>(props);
consumer.subscribe(Collections.singletonList(TOPIC));
} catch (KafkaException ke){
// here comes code that restarts consumer
}
But, whenever the use-case, changing this configuration would require client re-authorization, that would disrupt consumption/producing of records.但是,只要用例更改此配置,就需要客户端重新授权,这会破坏记录的消费/生产。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.