Enables developers to use AWS Identity and Access Management (IAM) to connect to their Amazon Managed Streaming for Apache Kafka (Amazon MSK) clusters.
Apache License 2.0
137
stars
65
forks
source link
How to set java system property of AKSK porperly with springboot #100
I used to set env before my spingboot starts, and everything is fine.
Now I need to decrypt AKSK when the application starts, therefore I tried to set java system property in the event listener as below, but it seems does not work for the kafka client.
Does anyone have any sample of working with springboot?
public class AfterConfigListener implements SmartApplicationListener, Ordered {
@Override
public boolean supportsEventType(Class<? extends ApplicationEvent> aClass) {
return (ApplicationEnvironmentPreparedEvent.class.isAssignableFrom(aClass)) ||
ApplicationPreparedEvent.class.isAssignableFrom(aClass) ||
ApplicationStartingEvent.class.isAssignableFrom(aClass);
}
@Override
public void onApplicationEvent(ApplicationEvent applicationEvent) {
if (applicationEvent instanceof ApplicationStartingEvent){
System.setProperty("aws.accessKeyId","asfd");
System.setProperty("aws.secretAccessKey","asdf/abcdefg");
}
}
@Override
public int getOrder(){
return(ConfigFileApplicationListener.DEFAULT_ORDER + 1);
}
}
I used to set env before my spingboot starts, and everything is fine. Now I need to decrypt AKSK when the application starts, therefore I tried to set java system property in the event listener as below, but it seems does not work for the kafka client. Does anyone have any sample of working with springboot?
application.yml:
build.gradle: