MSA 27

[MSA] Spring Boot - RestTemplate 란? 사용

RestTemplate Spring에서 지원하는 간편하게 Rest API를 호출할 수 있게 해주는 클래스 Application - Bean 등록 @LoadBalanced // 마이크로 서비스 이름으로 찾을 수 있게 해 줌 package com.gugbab.gugbabservices; import ... @SpringBootApplication @EnableDiscoveryClient public class GugbabServicesApplication { ... @Bean @LoadBalanced public RestTemplate getRestTemplate(){ return new RestTemplate(); } } RestTemplate 사용 예시 public class UserServicesIm..

MSA 2023.04.23

[MSA] Spring Boot - Spirng Cloude Bus (RabbitMQ)

Spring Cloude Bus 분산 시스템에서 구성 변경 사항을 전파하는 라이브러리 구성 변경 사항이 발생하면, 해당 변경 사항을 구독한 모든 인스턴스에 대해 자동으로 전파되어 구성 변경을 쉽게 처리할 수 있다. AMQP (Advanced Message Queuing Protocol) 메세지 지향 미들웨어를 위한 개방형 표준 으용 계층 프로토콜 Kafka 분산형 스트리밍 플랫폼 대용량의 데이터를 처리 가능한 메시징 시스템 초당 100k+ 이상의 이벤트 처리 pub/sub, Topic에 메시지 전달 Ack를 기다리지 않고 전달 가능 생산자 중심 RabbitMQ 초당 20+ 메시지를 소비자에게 전달 메시지 전달 보장, 시스템 간 메시지 전달 브로커, 소비자 중심 RabbitMQ 설치 (MAC) brew u..

MSA 2023.04.13

[MSA] Spring Boot - Actuator(엑츄에이터) 란? 사용

Actuator 란? 애플리케이션의 내부를 볼 수 있게 하고, 애플리케이션의 작동 방법을 제어할 수 있게 한다. 의존성 주입 (build.gradle) dependencies { implementation 'org.springframework.boot:spring-boot-starter-actuator' ... } 설정 파일 (application.yml) management: endpoints: web: exposure: include: refresh, health, beans, httptrace Actuator의 refresh 를 호출하면 서버 재시동 없이 설정파일을 다시 가져온다.

MSA 2023.04.12

[MSA] Spring Boot - Spring Cloude Config 란? Config Server 생성

Spring Clude Config 마이크로서비스 아키텍처에서 구성 요소의 구성 관리를 위한 도구 중앙 집중식 구성 서버에서 구성 정보를 저장하고, 클라이언트는 이 서버에서 구성 정보를 가져와서 자신의 설정에 적용한다. application.yml 우선순위 application.yml -> applicatoin-name.yml -> application-name- ConfigServer 의존성 주입 (build.gradle) ext { set('springCloudVersion', "2021.0.6") } dependencies { implementation 'org.springframework.cloud:spring-cloud-config-server' ... } 어플리케이션 부분에 컨피그 서버 등..

MSA 2023.04.11

[MSA] Spring Boot - Api Gateway [Spring Cloud Gateway]란? 생성

Api Gateway 마이크로 서비스들이 제공하는 api들은 동적으로 IP,와 포트가 바뀝니다. 그 정보들을 front에서 알수있게 라우팅 기능을 합니다. Spring Cloud Gateway Spring 환경의 gateway로 비동기 처리가 가능하다. (tomcat말고 Netty 등 비동기 서버 사용해야함) 의존성 주입 (build.gradle) ext { set('springCloudVersion', "2021.0.6") } dependencies { implementation 'org.springframework.cloud:spring-cloud-starter-gateway' implementation 'org.springframework.cloud:spring-cloud-starter-netfli..

MSA 2023.04.06

[MSA] Spring Boot - Netfix Eureka 란? 생성

Netflix Eureka 넷플릭스에서 MSA를 위해 Spring Cloud에 기부한 오픈 소스이다. MSA에서 서비스들에 대한 정보를 저장하여 외부에서 서비스 호출 시 그에 맞는 서비스 서버로 전달해주는 미들웨어이다. 의존성 주입 (build.gradle) // 스프링 클라우드 버전 ext { set('springCloudVersion', "2021.0.6") } dependencies { implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server' testImplementation 'org.springframework.boot:spring-boot-starter-test' ... } 어플리케이션 부분에 유레카..

MSA 2023.04.04