Spring
-
spring cloud gateway로 들어오는 요청spring cloud gateway에서 route를 호출하는 요청 이렇게 두 가지의 http 요청의 keepalive 설정을 어떻게 하는지 알아보자. HttpServerclient -> spring cloud gateway이렇게 요청이 들어오는 상황에서 scg는 서버 역할에 해당한다. HttpServer의 keepalive 설정은 따로 없는 것으로 파악된다. 따라서, client에서 보내는 요청에 따라서 keepalive가 유지되거나 안되거나 할 수 있다.client가 만약 nginx인 경우에는 nginx upstream 설정을 통해서 keepalive 설정을 조절할 수 있다.해당 내용은 이 포스팅을 참고하자. HttpClient spring cl..
[SpringCloudGateway] Keepalive 설정(server,client)spring cloud gateway로 들어오는 요청spring cloud gateway에서 route를 호출하는 요청 이렇게 두 가지의 http 요청의 keepalive 설정을 어떻게 하는지 알아보자. HttpServerclient -> spring cloud gateway이렇게 요청이 들어오는 상황에서 scg는 서버 역할에 해당한다. HttpServer의 keepalive 설정은 따로 없는 것으로 파악된다. 따라서, client에서 보내는 요청에 따라서 keepalive가 유지되거나 안되거나 할 수 있다.client가 만약 nginx인 경우에는 nginx upstream 설정을 통해서 keepalive 설정을 조절할 수 있다.해당 내용은 이 포스팅을 참고하자. HttpClient spring cl..
2025.09.04 -
스프링에서 WebClient를 사용한다면 Client별(AserviceWebClient, BserviceWebClient..)로 WebClient를 생성하던가, Bean으로 하나를 만들어 공유해서 사용할 것이다. WebClient를 생성하는 경우에 어떤 식으로 생성하는지 어떻게 Connection, Timeout 설정을 넣는지 자세히 알아보자. WebClient 생성WebClient webClient = WebClient.create("http://localhost:8080");WebClient webClient2 = WebClient.builder() .baseUrl("http://localhost:8080") .build(); 기본 생성은 url 정도만 넣고 ..
[Spring] WebClient - connection, timeout 설정스프링에서 WebClient를 사용한다면 Client별(AserviceWebClient, BserviceWebClient..)로 WebClient를 생성하던가, Bean으로 하나를 만들어 공유해서 사용할 것이다. WebClient를 생성하는 경우에 어떤 식으로 생성하는지 어떻게 Connection, Timeout 설정을 넣는지 자세히 알아보자. WebClient 생성WebClient webClient = WebClient.create("http://localhost:8080");WebClient webClient2 = WebClient.builder() .baseUrl("http://localhost:8080") .build(); 기본 생성은 url 정도만 넣고 ..
2025.08.21 -
HttpClientCustomizerSpring Cloud Gateway의 HttpClientCustomizer 인터페이스는 gateway에서 사용하는 HTTP 클라이언트를 커스터마이징 할 수 있게 해 준다Spring Cloud Gateway에서는 내부적으로 reactor.netty.http.client.HttpClient를 사용하여 백엔드 서비스로 요청을 보낸다.HttpClient를 커스터마이징하고 싶을 때 사용하는 것이 바로 HttpClientCustomizer 인터페이스이다.하나의 메서드인 customize를 제공하며, 이 메서드는 HttpClient 객체를 매개변수로 받아 수정된 버전을 반환한다.타임아웃 설정, 커스텀 헤더 추가, 특정 기능 활성화 등 HTTP 클라이언트에 대해 특별한 설정이나 동..
[SpringCloudGateway] HttpClientCustomizer&RouteDefinitionLocatorHttpClientCustomizerSpring Cloud Gateway의 HttpClientCustomizer 인터페이스는 gateway에서 사용하는 HTTP 클라이언트를 커스터마이징 할 수 있게 해 준다Spring Cloud Gateway에서는 내부적으로 reactor.netty.http.client.HttpClient를 사용하여 백엔드 서비스로 요청을 보낸다.HttpClient를 커스터마이징하고 싶을 때 사용하는 것이 바로 HttpClientCustomizer 인터페이스이다.하나의 메서드인 customize를 제공하며, 이 메서드는 HttpClient 객체를 매개변수로 받아 수정된 버전을 반환한다.타임아웃 설정, 커스텀 헤더 추가, 특정 기능 활성화 등 HTTP 클라이언트에 대해 특별한 설정이나 동..
2025.06.10 -
Spring-cloud-gateay에서 아래의 플로우로 호출이 존재할 때 Client - spring-cloud-gateway -> backendbackend로부터 온 응답을 확인하고 싶은 경우에 어떻게 response 내용을 조회할 수 있는지 알아보자.기본으로 제공되는 필터들 중에 response를 조회하거나 조작하는 필터는 두 가지를 발견할 수 있었다. ModifyRequestBody GatewayFilter FactoryThe Netty Write Response Filter각각의 필터에서 응답을 읽는 부분을 참고해 보면ModifyRequestBody GatewayFilter Factory에서는 ServerHttpResponseDecorator를 이용해 exchange의 응답값을 읽어 들인다. 간..
[SpringCloudGateway] Response Body 확인/수정Spring-cloud-gateay에서 아래의 플로우로 호출이 존재할 때 Client - spring-cloud-gateway -> backendbackend로부터 온 응답을 확인하고 싶은 경우에 어떻게 response 내용을 조회할 수 있는지 알아보자.기본으로 제공되는 필터들 중에 response를 조회하거나 조작하는 필터는 두 가지를 발견할 수 있었다. ModifyRequestBody GatewayFilter FactoryThe Netty Write Response Filter각각의 필터에서 응답을 읽는 부분을 참고해 보면ModifyRequestBody GatewayFilter Factory에서는 ServerHttpResponseDecorator를 이용해 exchange의 응답값을 읽어 들인다. 간..
2025.06.06