마이크로서비스 간 통신 구조

각 마이크로서비스(User, Order 등)는 Gateway를 통해서만 외부 요청을 받고, 서비스 간 통신은 FeignClient 를 사용

스크린샷 2025-09-25 오전 11.11.29.png

스크린샷 2025-09-25 오후 2.14.11.png

전체구조

[사용자 요청]
     ↓
 Gateway (8000)
     ↓
 User-Service (예: 8001)
     ↓
 OrderServiceClient (Feign)
     ↓
 Gateway (다시 8000으로 재요청)
     ↓
 Order-Service (예: 8002)

@FeignClient

스크린샷 2025-10-10 오전 1.07.02.png

스크린샷 2025-10-09 오후 6.19.33.png

항목 설명
name = "haeone-order-serivce" 이건 Eureka에 등록된 서비스 이름 (Gateway에선 lb://HAEONE-ORDER-SERVICE)
url = "localhost:8000" Gateway 주소 — 즉, 모든 통신은 Gateway를 통해서만 이뤄짐
FeignClientConfig.class 통신 시 Authorization 같은 헤더를 자동으로 넘겨주는 설정 (토큰 유지용)
@GetMapping(...) 실제 호출할 API 경로, Gateway가 /order-service/** 로 라우팅 규칙을 가짐

→ UserService는 게이트웨이 8000으로 /order-service/users/{userId}/orders 호출해줘


Gateway를 거쳐가는 이유

MSA 구조에서 Gateway는 보안 + 라우팅 허브 역할