Search code examples
apache-kafkakafka-consumer-apikafka-producer-api

Does kafka java client provides process level (system variable) properties support?


In my java project we created kafka producer and consumers from different places as and when required. Now i want to configure SSL on brokers. its working perfectly fine if i configure below properties on each producer and consumer in java :

            kafkaClientProperties.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL"); 
            kafkaClientProperties.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, this.keystore); 
            kafkaClientProperties.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, this.keyStorePassword); 
            kafkaClientProperties.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, this.trustStore);
            kafkaClientProperties.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, this.trustStorePassword);
            kafkaClientProperties.put(SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, ""); 

but i have to set these properties on each producer and consumer in my application. is there any way by which i can set these common properties at process level (e.g system variable) , so that i can avoid code changes at multiple places.

For a reference : I recently configured ssl on solr , and solrj client has this facility that we can set system property and solrj clinet will read it internally.


Solution

  • Kafka clients do not fetch configs from System properties outside of JAAS config (i.e. standard JVM properties)

    Sounds like you just need a standard library refactoring or use a higher level config templating like Spring offers