====== WebClient ====== * [[springframework:webflux|Spring WebFlux]] 와 함께 사용할 ''RequestTemplat'' 대체 라이브러리 * see [[springframework:feign|Fegin]] ===== Connection Pool ===== * [[https://github.com/reactor/reactor-netty|reactor-netty]]를 사용함. * [[https://github.com/reactor/reactor-netty/blob/master/src/main/java/reactor/netty/resources/ConnectionProvider.java|ConnectionProvider]]를 보면 ''ReactorNetty.POOL_MAX_CONNECTIONS - reactor.netty.pool.maxConnections'' 시스템 프라퍼티 값으로 설정하거나 혹은 자동 계산됨. (자동 계산을 믿는게 나을 듯) ===== timeouts ===== * [[https://howtodoinjava.com/spring-webflux/webclient-set-timeouts/|Spring WebClient - How to set timeouts - HowToDoInJava]] * [[https://akageun.github.io/2019/06/23/spring-webflux-tip-2.html|[Webflux Tip] 2. WebClient 설정(connection pool, timeout) · 오늘도 개발자]] * [[https://medium.com/@kalpads/configuring-timeouts-in-spring-reactive-webclient-4bc5faf56411|Configuring timeouts in Spring reactive WebClient | by Kalpa Senanayake | Medium]] ===== uri 생성시 주의점 ===== * ''UriBuilder''를 사용해야하면, 전체를 ''webClient.get().uri("/...?param1=value1¶m2=value2...")'' 형태로 할경우 [[springframework:springboot:micrometer|SpringBoot Micrometer]] 태그 과다 생성으로 문제가 발생한다. * uri 함수중에서 uriTemplate 를 파라미터로 받는 uri 함수를 사용해야 정상적으로 메트릭 태그가 path 로 등록됨. * ''UriBuilder.path()'' 를 사용하면 안됨. ===== 참조 ===== * [[https://www.baeldung.com/spring-5-webclient|Spring 5 WebClient | Baeldung]] * [[https://www.e4developer.com/2018/05/31/webflux-in-practice-asynchronous-service-with-webclient/|WebFlux in practice – asynchronous service with WebClient | E4developer]] * [[https://www.callicoder.com/spring-5-reactive-webclient-webtestclient-examples/|Spring 5 WebClient and WebTestClient Tutorial with Examples | CalliCoder]] * [[https://www.baeldung.com/spring-log-webclient-calls|Logging Spring WebClient Calls | Baeldung]] * [[https://dzone.com/articles/unit-tests-for-springs-webclient|Unit Tests for Spring's WebClient - DZone Java]] * [[https://dzone.com/articles/resttemplate-vs-webclient|RestTemplate vs. WebClient - DZone Java]] * [[https://www.baeldung.com/spring-webclient-resttemplate|Spring WebClient vs. RestTemplate | Baeldung]]