0

I am using a Kafka Producer with SSL authentication and setting kafka.ssl.keystore.location = C:\\Users\\Documnets\\filelocation.jks. There is another bean which needs to be started prior to my producer, and it uses the producer So, I am auto-wiring this Producer with its config in that initializing bean.

Somehow, @Value(${kafka.ssl.keystore.location}), can't be resolved. I get Placeholder couldn't be resolved error.

Kerem
  • 11,377
  • 5
  • 59
  • 58

1 Answers1

0

It's spring.kafka.ssl.key-store-location. But, you should never, never, invoke a producer from an initialization method; it's too early. Implement SmartLifecycle instead and put your code in the start() method.

Set the phase to Integer.MIN_VALUE so it is started very early.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • `>The send method of Producer is called in my initialising bean itself .` I will repeat - sending to a producer during bean initialization is too early. – Gary Russell May 14 '20 at 02:44
  • Thanks for answering Gary ! That solved. I now deployed my code to Kubernetes and created a secret for jks under volume mount /etc/secrets/keystore. I am trying accessing jks in my code setting ssl.keystore.location to file:///etc/secrets/keystore/ssl.jks. I get no file found exception now :( – victor perfect May 15 '20 at 05:23
  • See https://stackoverflow.com/questions/61812478/ssl-keystore-location-cant-find-jks-file-in-my-kubernetes-secrets-mount/61820030#61820030 – Gary Russell May 15 '20 at 13:25