Spring Cloud Bus

이재철·2021년 9월 12일
0

MSA

목록 보기
5/13
  1. 서버 재기동
    • 의미 없음
  2. Actuaor refresh
    • 서버가 한 두개일 경우 괜찮지만 여러 개일 경우 수동으로 처리해줘야하기때문에 번거로움
  3. Spring cloud bus
    • 분산 시스템의 노드(Micro Service)를 경량 메시지 브로커(RabiitMQ)와 연결
    • 상태 및 구성에 대한 변경 사항을 연결된 노드에게 전달 (Broadcast)
    • AMQP -> Spring Cloud Config Server + Spring Cloud Bus

AMQP (Advanced Message Queuing Protocol)

  • 메시지 지향 미들웨어를 위한 개방형 표준 응용 계층 프로토콜
  • 메시지 지햐으 큐이으 라우팅(P2P, Publisher-Subscriber), 신뢰성, 보안
  • Erlang, RabbitMQ에서 사용

Kafka 프로젝트

  • 오픈 소스 메시지 브로커 프로젝트
  • 분산형 스트리밍 플랫폼
  • 대용량 데이터를 처리 가능한 메시징 시스템

RabbitMQ vs Kafka

Rabbit

  • 메시지 브러커
  • 초당 20개 이상 메시지를 소비자에게 전달
  • 메시지 전달 보장, 시스템 간 메시지 전달
  • 브로커, 소비자 중심

Kafka

  • 초당 100k+ 이상의 이벤트 처리
  • Pub/Sub, Topic에 미시지 전달
  • Ack를 기다리지 않고 전달 가능
  • 생산자 중심

RabbitMQ Install

brew update
brew install rabbitmq

python관련 오류 해결

xcode-select --install

설치 경로

  • /usr/local/sbin

실행 시 url

  • 127.0.0.1:15672

초기 계정, 비밀번호

  • guest

config-service

  • pom.xml 추가
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bootstrap</artifactId>
        </dependency>
  • application.yml
spring:
  rabbitmq:
    host: 127.0.0.1
    port: 5672 # rabbitmq 서버를 실행하고 들어갈 때에는 15672이고 여기서는 5672임.
    username: guest
    password: guest
    
management:
  endpoints:
    web:
      exposure:
        include: health, busrefresh

api, user-service

  • pom.xml 추가
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
        </dependency>
  • application.yml
spring:
  rabbitmq:
    host: 127.0.0.1
    port: 5672 # rabbitmq 서버를 실행하고 들어갈 때에는 15672이고 여기서는 5672임.
    username: guest
    password: guest
    
management:
  endpoints:
    web:
      exposure:
        include: ..., busrefresh

참고 사항

  • amqp는 2.5.3 이상부터 에러가 발생함 -> 2.5.2버전으로 해서 하자!

0개의 댓글