Reputation: 1
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?
Upvotes: 0
Views: 999
Reputation: 265
If you want to manually set your own connection-string. Kindly disable/exclude the autoconfiguration file that using the AzureServiceBusJMSProperties and you also need to create the bean required in that excluded file.
Take a look at Azure service bus configuration via code spring
Upvotes: 0
Reputation: 2439
@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();
}
@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;
}
Upvotes: 0