项目作者: PheaSoy

项目描述 :
Spring Cloud Config integrate Bus Bind with RabbitMQ as message broker.
高级语言: Shell
项目地址: git://github.com/PheaSoy/spring-cloud-config.git
创建时间: 2020-04-29T15:31:31Z
项目社区:https://github.com/PheaSoy/spring-cloud-config

开源协议:

下载


Spring Cloud Config + Bus

Use case

  • book-service -> configure-server -> github
  • book-service will pull the configuration on the startup

Getting Start

  • Clone or download the project
  • Go to the spring-cloud-config and running following command
    shell script docker-compose up -d
    book-service is running on port 8082

configure-server is running on port 8081

  • Accessing the book controller

```shell script
http http://localhost:8082/books

  1. * Result
  2. ```json
  3. {
  4. "author": "Jose Long",
  5. "price": 10.0,
  6. "title": "Cloud-Native Java",
  7. "totalPrice": 11.0
  8. }

On the BookController class we inject the tax from PropertySource to calculate the total price

  1. @Value("${tax:0.0}")
  • Let’s change the configuration book-service.yaml then commit the changes
    ```yaml

management:
endpoints:
web:
exposure:
include: ‘*’
rabbitmq:
username: guest
password: guest
port: 5672
host: localhost
server:
port: 8082

tax: 30

  1. * After we changed and commit - we need to call the configure-server and tell we need to refresh the configuration.
  2. ```shell script
  3. http POST http://localhost:8081/actuator/bus-refresh/book-service:**
  • Let’s access the book API again
    shell script http http://localhost:8082/books
  • Result
    1. {
    2. "author": "Jose Long",
    3. "price": 10.0,
    4. "title": "Cloud-Native Java",
    5. "totalPrice": 13.0
    6. }