본문 바로가기
study/Spring

Spring Cloud Bus with RabbitMQ

by stilinski 2022. 10. 18.
728x90

Spring Cloud Bus 

micro service들이 가동중에도 config server의 변경된 것들이 적용되게끔 해주는 것.

 

AMQP

Advanced Message Queuing Protocol

비동기적으로 무언갈 함

 

RabbitMQ

  • Messaging Broker,
  • It is an intermediary for messaging,
  • It gives applications a common platform to send and receive messages, and for messages a safe place to live until they are received.

<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

actuator - help monitoring ms

 

 

config 설정 다이나믹하게 하고싶은 ms에 amqp디펜던시 모두 추가

 

 

설정을 바꾸고 모든 ms에 적용하려면 POST /bus-refresh config server에 보내야함.

config server properties파일에

management.endpoints.web.exposure.include=busrefresh

 

RabbitMq깔기

https://evandde.github.io/chocolatey/

초코깔기

https://www.rabbitmq.com/install-windows.html

rabbitMq 깔기

https://oingdaddy.tistory.com/165

설치 후 실행 참고

 

 

rabbitmq 필요한 곳에 다 추가.

spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

 

 

configuration 바꾸고

broadcast를 위해 config server에 post리퀘 보내보기

Post로!

 

https://docs.spring.io/spring-cloud-bus/docs/current/reference/html/

 

Spring Cloud Bus

The bus tries twice to eliminate processing an event — once from the original ApplicationEvent and once from the queue. To do so, it checks the sending service ID against the current service ID. If multiple instances of a service have the same ID, ev

docs.spring.io

 

728x90

댓글