spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.96k stars 1.29k forks source link

[Question] How to broadcast refresh through all clients without webhook #733

Closed regardfs closed 7 years ago

regardfs commented 7 years ago

I read the note from Spring-cloud-config

the default configuration also detects filesystem changes in local git repositories (the webhook is not used in that case but as soon as you edit a config file a refresh will be broadcast).

Does this mean no dependency of spring-cloud-config-monitor and no /endpoint of /monitor, just enable and config rabbitmq info it will refresh all spring-cloud-config client? But indeed, it would not work.. Could u guys show me an example of how to fulfill this scenario?? Thanks a lot

ryanjbaxter commented 7 years ago

Have your tried adding spring-cloud-bus and spring-cloud-monitor to the classpath? Does it work then?

regardfs commented 7 years ago

@ryanjbaxter hi, Sure, it works, I followed this page asimio's toturial and everything goes fine when git push happens , clients automatically refresh by themselves. when I saw the official site Note about absence of webhook of git, I want to use this pattern cause I have many repos for huge of projects, it is not a best practice for configure webhook on these repos.

the default configuration also detects filesystem changes in local git repositories (the webhook is not used in that case but as soon as you edit a config file a refresh will be broadcast).

regardfs commented 7 years ago

@ryanjbaxter Does this default configuration means removing webhook only?

ryanjbaxter commented 7 years ago

So you are editing the file in your local git repo and not seeing a refresh event broadcasted?

regardfs commented 7 years ago

@ryanjbaxter yes,so I posted a issue and question here. Here is my configurations:

application.yml

spring:
cloud:
config:
server:
git:
uri: http://192.168.100.22/devops/spring-cloud-configs.git
search-paths: test1/
username: leo
password: 1366662Ti
bus:
enabled: true
trace:
enabled: true
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
profiles:
active: config-monitor
server:
port: 8003

bootstrap.yml


spring:
application:
name: configurations``

and dependencies same as official

                 <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-monitor</artifactId>
            <version>1.3.1.RELEASE</version>
        </dependency>
                <dependency>
                       <groupId>org.springframework.cloud</groupId>
                       <artifactId>spring-cloud-starter-bus-amqp</artifactId>
                       <version>1.3.1.RELEASE</version>
                </dependency>`

When config web hock as http://192.168.100.201:8003/monitor, everything goes fine, when remove hook, could not refresh.
Furthermore, you know if you have hundreds of micro services , it is not best practice to config webhook one by one, I am try to use post method when something change on local repo with cmd like 

`curl -v -X POST "http://localhost:8003/monitor" -H "Content-Type: application/json" -H "X-Event-Key: repo:push" -H "X-Hook-UUID: webhook-uuid" -d '{"push": {"changes": []} }'
`
regardfs commented 7 years ago

@dsyer, might u cc this issue? I have hacked spring-cloud-bus and found it use this class RefreshRemoteApplicationEvent to refresh.

spencergibb commented 7 years ago

There is no way to broadcast refresh requests without /monitor or by triggering a manual refresh using /bus/refresh unless you code something by hand.

regardfs commented 7 years ago

@spencergibb , Yeah I saw the code, I try to make a curl request to simulate the request to monitor like

curl -v -X POST "http://localhost:8003/monitor" -H "Content-Type: application/json" -H "X-Event-Key: repo:push" -H "X-Hook-UUID: webhook-uuid" -d '{"push": {"changes": []} }'

regardfs commented 7 years ago

@spencergibb I have finish this task with urlconnection and simulate the request above. Thanks all you guys, I will close this question.