zoukankan      html  css  js  c++  java
  • kafka sasl & java api

    第一种

    Properties props = new Properties();
    props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, “node01:9092”);
    props.put(“acks”, “all”);
    props.put(“retries”, 0);
    props.put(“batch.size”, 16384);
    props.put(“linger.ms”, 1);
    props.put(“buffer.memory”, 33554432);
    props.put(“key.serializer”, “org.apache.kafka.common.serialization.StringSerializer”);
    props.put(“value.serializer”, “org.apache.kafka.common.serialization.StringSerializer”);

    props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, “SASL_PLAINTEXT”);
    props.put(SaslConfigs.SASL_MECHANISM, “PLAIN”);
    props.put(“sasl.jaas.config”,
    “org.apache.kafka.common.security.plain.PlainLoginModule required username=”maoxiangyi” password=”123321”;”);


    第二种

    System.setProperty(“java.security.auth.login.config”, “/software/servers/maoxiangyi/kafka_client_jass.conf”); //配置文件路径


    第三种

    可以在程序启动参数中设置java.security.auth.login.config, 也就是启动参数加上-Djava.security.auth.login.config=/software/servers/maoxiangyi/kafka_client_jass.conf

    java -jar -Djava.security.auth.login.config=/software/servers/maoxiangyi/kafka_client_jass.conf xxx.jar

  • 相关阅读:
    BugReport-仿微信app
    成长、责任、和公司的关系
    团队如何做决定
    课堂练习
    课堂练习
    NABCD model
    课堂练习
    日程管理测试用例
    测试
    Bug报告
  • 原文地址:https://www.cnblogs.com/maoxiangyi/p/11003315.html
Copyright © 2011-2022 走看看