목록전체 글 (49)
사붐이개발일기
개요 Spring Framework은 다양한 HTTP 요청 방식을 지원하여 웹 서비스와의 통신을 할 수 있습니다. 이 포스팅에서는 Spring에서 사용하는 주요 HTTP 요청 방식인 RestTemplate, WebClient, 그리고 OpenFeign에 대해 알아보겠습니다. 각각의 특징, 사용법, 그리고 장단점을 살펴보면서 Spring에서의 HTTP 통신을 깊이 이해할 수 있습니다. 1. RestTemplate RestTemplate은 Spring Framework에서 제공하는 동기식 HTTP 통신을 위한 클라이언트입니다. RestTemplate은 주로 Spring MVC 기반의 애플리케이션에서 사용되며, 다양한 HTTP 메서드(GET, POST, PUT, DELETE 등)를 지원하고 JSON, XML ..
Spring Cloud Bus란? MSA구조에서 마이크로서비스를 메세지 브로커와 연결해주는 역할과 상태 및 구성에 대한 변경사항을 연결된 모든 마이크로서비스에게 전달해주는 프레임워크이다. 어플리케이션 설정파일 변경 시 Spring Cloud Config를 이용하면 어플리케이션 별도 빌드-배포 없이 적용 가능할 수 있다. 그러나 MSA 구조에서 Micro Service가 많아질 경우 서버 한개 한개 각각 개별적으로 actuator/refresh를 호출하여 적용하는 것은 실용적이지 못하고 누락의 가능성이 있다. 이러한 복잡하고 번거로운 점을 개선하고자 Spring Cloud Bus에선 손쉽게 적용할 수 있도록 도와준다. Spring Cloud Bus는 분산 시스템의 노드(Micro Service)를 경량 메..
RabbitMQ란? RabbitMQ는 AMQP를 따르는 오픈소스 메시지 브로커이다. producers에서 consumers로 메세지(요청)를 전달할 때 중간에서 브로커 역할을 한다. 사용하는 케이스는 다음과같다. 요청을 많은 사용자에게 전달할 때 요청에 대한 처리시간이 길 때 해당 요청을 다른 API에게 위임하고 빠른 응답을 할 때 또한 MQ를 사용하면 애플리케이션 간 결합도를 낮출 수 있다는 장점도 가진다. AMQP란? AMQP란 인스턴스가 데이터를 서로 교환할 때 사용하는 방법이다. Advanced Message Queueing Protocol의 줄임말로 MQ의 오픈소스에 기반한 표준 프로토콜을 의미한다. APQP 자체가 프로토콜을 의미하기 때문에 이 프로토콜을 구현한 MQ제품들은 여러가지가 있으며 ..
참고 1. Spring Cloud Config 정리 잘되있음 https://velog.io/@hyun-jii/Spring-Cloud-Config-%EA%B0%9C%EB%85%90-%EB%B0%8F-%EC%84%A4%EC%A0%95-%EB%B0%A9%EB%B2%95 Spring Cloud Config란 분산 시스템에서 서버, 클라이언트 구성에 필요한 설정 정보(application.yml)를 외부 시스템에서 관리 하나의 중앙화 된 저장소에서 구성요소 관리 기능 각 서비스를 다시 빌드하지 않고, 바로 적응 가능 애플리케이션 배포 파이프라인을 통해 DEV-UAT-PROD 환경에 맞는 구성 정보 사용 깃에 저장하는것이 일반적 configrationg 우선순위 application.yml -> applicatio..
vo.RequestLogin @Data public class RequestLogin { @NotNull(message = "Email cannot be null") @Size(min = 2, message = "Email not be less than two characters") @Email private String email; @NotNull(message = "Password cannot be null") @Size(min = 8, message = "Password not be equals or grater than 8 characters") private String password; } dto.UserDto @Data public class UserDto { private String em..
ApiGateway application.yml server: port: 8000 eureka: client: register-with-eureka: true fetch-registry: true service-url: defaultZone: http://localhost:8761/eureka spring: application: name: apigateway-service cloud: gateway: default-filters: - name: GlobalFilter args: baseMessage: Spring Cloud Gateway Global Filter preLogger: true postLogger: true routes: # - id: user-service # uri: lb://USER-..
WebConfig@Configuration @EnableWebSecurity public class WebSecurity { private static final String IP_ADDRESS = "172.0.0.1"; private static final String SUBNET = "/32"; private static final IpAddressMatcher IP_ADDRESS_MATCHER = new IpAddressMatcher(IP_ADDRESS + SUBNET); private static final String[] WHITE_LIST = { "/**", "/users/**" }; @Bean protected SecurityFilterChain filterChain(HttpSecurity ..
1. 의존성 추가 build.gradle dependencies { // 객체를 변환해주는 라이브러리 (DTO -> Entity) implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.2.0' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' } 2. DTO 생성 OrderDto @Data public class OrderDto implements Serializable { private String productId; private Integer qty; private Integer unitPrice; private Integer totalPrice..