Spring Cloud Config Client connecting to RabbitMQ -
i have been trying set spring cloud config server/client. have been following few different examples (1, 2). have client , server set correctly , can query localhost:8888/localhost:8080 see values in json format.
my question whether spring boot automatically detect these properties provided spring cloud config server. attempting connect rabbitmq instance on startup have had no success despite not having errors. not connect rabbit or create queues/exchanges.
it works when have application.properties file locally following properties wish these setting through spring cloud config github repository.
spring.rabbitmq.host=178.61.47.--- spring.rabbitmq.port=5672 spring.rabbitmq.username=mqtt spring.rabbitmq.password=mqtt
i have looked through questions here/issues on github can't see relating this.
code client class below:
@enableautoconfiguration @componentscan @springbootapplication public class configrabbitapplication { final static string queuename = "arduino-weather-queue"; @autowired rabbittemplate rabbittemplate; @bean queue queue() { return new queue(queuename, true); } @bean binding binding(queue queue, topicexchange exchange) { return bindingbuilder.bind(queue).to(exchange).with("arduino-weather"); } @bean topicexchange exchange() { return new topicexchange("arduino-iot-exchange", true, false); } public static void main(string[] args) { springapplication.run(configrabbitapplication.class, args); } }
no, spring boot client not aware want fetch configuration config-server. loaded when specific class in on classpath, thats why have add org.springframework.cloud:spring-cloud-starter-config
dependency. described here: http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_client_side_usage
in case config-server not on localhost:8888 have add:
spring.cloud.config.uri: http://myconfigserver.com
to bootstrap.yml file ( same application.yml, loaded earlier ).
Comments
Post a Comment