TIL

2021.07.31 기록장

Gisungcu 2021. 7. 30. 21:39

ToDo

  • 알고리즘 2문제
  • 책 읽기

Done

  •  

Weekly goal

  • 책 읽기
  • 토비 스프링 코딩
  • 북마크 보기

restTamplate와 webClient

스프링 3에 추가된 restTamplate

스프링 5에 추가된 webClient

무엇을 사용해야 하는가? restTamplate는 곧 deprecated 될 운명이라고 한다.

왜 deprecated 되나? 일단 restTamplate는 동기 방식으로 작동한다. 요청당 스레드 하나를 사용하기에 서버 환경에서는 모든 스레드가 작동 중에는 느려지게 될 것이다. 

근데 webClient는 동기, 비동기 방식을 모두 지원한다. 또 이벤트루프방식으로 동작하기에 

스레드를 기다리지 않아도 됨

 

논블럭킹으로 작동하기에 컨트롤러는 값이 도착하기 전에 값을 먼저 리턴시켜 버린다.

 

https://umbum.dev/1114

 

[Spring] WebClient

왜 WebClient ?: RestTemplate은 deprecated 예정. docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html NOTE: As of 5.0 this class is in maintenanc..

umbum.dev

https://godekdls.github.io/Reactive%20Spring/webclient/

 

WebClient

스프링5 웹 리액티브 스택 WebClient 한글 번역

godekdls.github.io

https://timewizhan.tistory.com/entry/%EB%B2%88%EC%97%AD-Concurrency-in-Spring-WebFlux

 

[번역] Concurrency in Spring WebFlux

WebFlux에 대해 알아볼겸 아래 페이지를 번역해 보려고 한다. 개인적으로 이해하면서 쓰기 때문에 생략 및 의역이 많이 포함되어 있으므로 자세한 내용은 원문 참조 www.baeldung.com/spring-webflux-concurre

timewizhan.tistory.com

https://medium.com/@odysseymoon/spring-webclient-%EC%82%AC%EC%9A%A9%EB%B2%95-5f92d295edc0

 

Spring WebClient 사용법

Spring 어플리케이션에서 HTTP 요청을 할 땐 주로 RestTemplate 을 사용했었습니다. 하지만 Spring 5.0 버전부터는 RestTemplate 은 유지 모드로 변경되고 향후 deprecated 될 예정입니다.

medium.com