当前位置:   article > 正文

Kafka Client(Consumer)配置JAAS(ACL)_kafka consumer jaas

kafka consumer jaas
  1. Properties props = new Properties();
  2. props.put("bootstrap.servers", address);
  3. props.put("group.id", groupId);
  4. props.put("enable.auto.commit", "false");
  5. props.put("session.timeout.ms", "30000");
  6. props.put("auto.offset.reset", "latest");//latest ,earliest
  7. props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
  8. props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
  9. //配置JAAS(ACL),需要acl账号
  10. props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SASL_PLAINTEXT");
  11. props.put(SaslConfigs.SASL_MECHANISM, "PLAIN");
  12. props.put("sasl.jaas.config",
  13. "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"ckafka-jaop7o37#test\" password=\"*****\";");
  14. KafkaConsumer<String, String> kafkaConsumer = new KafkaConsumer<String, String>(props);
  15. kafkaConsumer.subscribe(Collections.singleton(topic));
  16. return kafkaConsumer;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/950972
推荐阅读
相关标签
  

闽ICP备14008679号