Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot YAML文件的Kafka Producer SSL属性_Spring Boot_Apache Kafka_Spring Kafka_Kafka Producer Api - Fatal编程技术网

Spring boot YAML文件的Kafka Producer SSL属性

Spring boot YAML文件的Kafka Producer SSL属性,spring-boot,apache-kafka,spring-kafka,kafka-producer-api,Spring Boot,Apache Kafka,Spring Kafka,Kafka Producer Api,这是YAML文件中的Kafka Producer属性。 当我启用SSL时,我的卡夫卡制作者无法工作。它无法在代理上识别主题。但是当我使用纯文本时,我的卡夫卡制作者工作正常。 我是否缺少SSL配置的某些内容 PS:Bootsrap服务器对于SSL和明文是不同的。 spring: kafka: producer: bootstrap-servers: <server name> properties: acks: al

这是YAML文件中的Kafka Producer属性。 当我启用SSL时,我的卡夫卡制作者无法工作。它无法在代理上识别主题。但是当我使用纯文本时,我的卡夫卡制作者工作正常。 我是否缺少SSL配置的某些内容

PS:Bootsrap服务器对于SSL和明文是不同的。

spring:
   kafka:
      producer:
        bootstrap-servers: <server name>
        properties:
          acks: all
          retries: 3 
          retry.backoff.ms: 200000
      ssl.protocol: SSL
      ssl.endpoint.identification.algorithm: https 
      ssl:
        keystore-location: keystore.jks
        keystore-password: password

您正在创建自己的
ProducerFactory
bean,因此
application.yml
中的属性没有被使用;引导在自动配置其bean时使用这些属性

您需要自己在
producerFactory()
bean中设置SSL属性

@Bean
    public ProducerFactory<String, JsonMessage> producerFactory() {
        Map<String, Object> config = new HashMap<>();

        config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
        config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
        config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);
        config.put(ProducerConfig.ACKS_CONFIG, acks);
        config.put(ProducerConfig.RETRIES_CONFIG, retries);
        config.put(ProducerConfig.RETRY_BACKOFF_MS_CONFIG, retryBackoffMs);
        
        


        return new DefaultKafkaProducerFactory<>(config);
    }

    @Bean
    public KafkaTemplate<String, JsonMessage> kafkaTemplate() {
        return new KafkaTemplate<>(producerFactory());
    }
ssl.keystore.location = null
ssl.keystore.password = null
ssl.keystore.type = JKS
ssl.protocol = TLS
ssl.provider = null
 ssl.secure.random.implementation = null