0

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?

link for lib code : https://github.com/Azure/azure-sdk-for-java/blob/e81850c3fcebe0bbfe65ed3e8a1c7c0c607798cf/sdk/spring/azure-spring-boot/src/main/java/com/azure/spring/autoconfigure/jms/AzureServiceBusJMSProperties.java

1 Answers1

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;
}
  • Also Check this SO for complete information and check this Github document if you are facing any issues regarding Netty Dependency.
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