MSA 공부 (AMQP) - 17

진병욱·2023년 11월 21일

Spring Cloud MSA 공부

목록 보기
17/20
post-thumbnail

먼저 글 작성에 앞서 해당 시리즈는 Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA) 강의를 참고하여 필요한 내용들을 정리한 것임을 밝힙니다.

AMQP 사용

종속성

// amqp
implementation 'org.springframework.cloud:spring-cloud-starter-bus-amqp'
// actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// bootstrap
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'

접속

  • 웹에서 접속할 때는 http://localhost:15672
  • AMQP 프로토콜을 사용할 때는 5672 포트로 연결

yaml (config, gateway, service)

management:
  endpoints:
    web:
      exposure:
        include: bus-refresh
        
spring:
  rabbitmq:
    host: [URI]
    port: [port]
    username: [username}
    password: [password]

위와 같이 RabbitMQ 설정을 해주면 하나의 설정이 변경되었을 때, 모든 서비스에 refresh 요청을 보낼 필요 없이 하나의 서비스에 http://서비스URI:[port]/actuator/busrefresh 로 POST요청을 보내면 변경사항이 모든 서비스에 적용된다.

profile
새로운 기술을 접하는 것에 망설임이 없고, 부족한 것이 있다면 항상 배우고자 하는 열정을 가지고 있습니다!

0개의 댓글