WebFlux 기반 Gateway vs Spring MVC 기반 Gateway 차이

  1. Route 설정 위치
    1. WebFlux : spring.cloud.gateay.server.webflux.routes
    2. MVC : spring.cloud.gateay.mvc.routes
  2. 내부 Dispatcher
    1. WebFlux (Reactor)
    2. Spring MVC (Servlet)
  3. 주요대상
    1. Reactive.Stack
    2. Blocking Stack / 전통적인 spring MVC 앱
  4. 특징
    1. WebFlux : 비동기 처리, Netty 서버 사용 가능
    2. MVC : 톰캣 기반, 일반 MVC 앱과 통합 쉬움

spring-boot 프로젝트 생성

  1. intellij new 프로젝트

    1. https://start.spring.io/ (커뮤니티 버전은 여기서 만들고 파일 오픈)
      1. Dependencies
        1. lombok
        2. Spring Boot DevTools
        3. Gateway
    2. YAML 설정
    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:
    		mvc:
    				route:
    					- id: first-service
    						uri: <http://localhost:8081/> 
    						predicates:
    							- Path-/first-service/** 
    							
    					- id: second-service
    						uri: <http://localhost:8082/>
    						predicates:
    							- Path-/first-service/**