Spring Cloud Config 와 RabbitMQ / Spring Cloud Bus AMQP / Spirng Actuator 연동을 통해 Config 설정 파일 변경 시 어플리케이션 재기동 없이 Hot-Deploy 기능을 수행하도록 설정한다.
- Spring Cloud Config 와 통신할 마이크로서비스는 Spring Cloud Bus AMQP, Spring Actuator 를 dependecy 설정한다.
- 각 마이크로서비스는 RabiitMQ 서버와 연동되도록 설정한다.
- RabbitMQ 는 연동된 마이크로서비스 별로 메세지 큐를 할당한다.
- Config 설정 파일이 변경 된다.
- POST /actuator/busresh REST API 요청을 통해 Bus 안에 연동된 마이크로서비스의 RabbitMQ 메세지 큐에 메시지가 등록된다.
- 연동된 마이크로서비스가 메시지 큐의 메시지를 Consume 하면서 서버 재기동 없이 Config 설정이 Reload 된다.
busrefresh 요청 (Config Server로 요청)

busrefresh 로 인한 Config 설정 relaod 로그

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(ConfigServerConfiguration.class)
public @interface EnableConfigServer {
}
@EnableConfigServer
@SpringBootApplication
public class ConfigServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServiceApplication.class, args);
}
}
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(ConfigServerConfiguration.Marker.class)
@ConditionalOnProperty(name = ConfigServerProperties.PREFIX + ".enabled", matchIfMissing = true)
@EnableConfigurationProperties(ConfigServerProperties.class)
@Import({ EnvironmentRepositoryConfiguration.class, CompositeConfiguration.class, ResourceRepositoryConfiguration.class,
ConfigServerEncryptionConfiguration.class, ConfigServerMvcConfiguration.class,
ResourceEncryptorConfiguration.class })
public class ConfigServerAutoConfiguration {
}
spring:
cloud:
config:
server:
git:
uri: git@github.com:onlydev7777/emotion-diary-conifg.git
default-label: main
private-key: |
-----BEGIN EC PRIVATE KEY-----
블라블라
-----END EC PRIVATE KEY-----
ignore-local-ssh-settings: true
host-key: 블라블라
host-key-algorithm: ecdsa-sha2-nistp256
bootstrap: true
rabbitmq:
host: 127.0.0.1
port: 5672
username: guest
password: guest
management:
endpoints:
web:
exposure:
include: health, busrefresh


encrypt:
key-store:
location: file://${user.home}/IdeaProjects/emotion-diary-msa/config-service/apiEncryptionKey.jks
password: 1q2w3e4r
alias: apiEncryptionKey
Diary-Service (일기 서비스) 의 Spring Cloud Config Client 관련 설정
management:
endpoints:
web:
exposure:
include: refresh, health, beans, httpexchanges, busrefresh, info, metrics, prometheus
spring:
cloud:
config:
uri: http://localhost:8888
name: ediary

Spring Cloud Config Server 와 연동된 Github Private Repository
Config Client 서비스 들은 해당 Repository 의 ediary 파일을 load 한다.

front-end("front-msa" 브랜치) : https://github.com/onlydev7777/emotion-diary-react
back-end : https://github.com/onlydev7777/emotion-diary-msa
inflearn-msa : https://github.com/onlydev7777/springboot-msa-3.0/tree/master