I am using azure-spring-boot-starter-servicebus-jms dependency to read messages from azure topic service bus. Currently the document says to provide connection-string in application properties but I need to read connection string from azure keyvault. Jms lib has AzureServiceBusJMSProperties which reads connection string from application.properties..so I am getting the error “spring.jms.servicebus.connection-string should be provided”. How to inject value, read from azure keyvault ,into this application properties?
Asked
Active
Viewed 633 times
1 Answers
0
- Here is the Sample Code of Data Source which reads all common properties from Application Properties
@Value("${db-user}")
String dbUser;
@Value("${db-password}")
String dbPwd;
@Bean
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource getDataSource() {
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.username(dbUser);
dataSourceBuilder.password(dbPwd);
return dataSourceBuilder.build();
}
- All the used values are injected as above using
@Value
-annotation
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
TomcatConnectorCustomizer tomcatConnectorCustomizer = connector -> {
connector.setPort(port);
connector.setScheme("https");
connector.setSecure(true);
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
protocol.setSSLEnabled(true);
protocol.setKeystoreType(keyStoreType);
protocol.setKeystoreProvider(keyStoreProvider);
protocol.setKeystoreFile(keyStorePath);
protocol.setKeystorePass(keyStorePassword);
protocol.setKeyAlias(keyAlias);
protocol.setTruststoreFile(trustStorePath);
protocol.setTruststorePass(trustStorePassword);
protocol.setSSLVerifyClient(clientAuth);
};
tomcat.addConnectorCustomizers(tomcatConnectorCustomizer);
return tomcat;
}

SaiSakethGuduru
- 2,218
- 1
- 5
- 15
-
Hey [Anjali Pharswan](https://stackoverflow.com/users/12013649/anjali-pharswan), has it solved your problem else you can share more details so I can troubleshoot? – SaiSakethGuduru May 10 '22 at 05:05