WebClient를 RestClient로 대체하는 것을 건의합니다. #20
sleepyhoon
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
건의 배경
implementation 'org.springframework.boot:spring-boot-starter-webflux의존성을 받아WebClient를 사용하고 있습니다. 이는 netty 를 활용하여 비동기 논블로킹 통신을 지원하는 클래스이지만, 근본적으로 spring web 을 사용하고 있어 Tomcat 을 기본으로 사용하기 때문에 비동기적 통신이 이뤄질 수 없습니다.건의 사항
RestClient를 사용하는 것을 건의합니다.도입해서 얻을 수 있는 이득?
RestTemplate의 경우 사용하면 코드가 지저분해지고, 오래된 클래스이지만RestClient의 경우 Spring 팀이 권장하는 최신 방식입니다. 메서드 체이닝 방식으로 코드를 깔끔하게 작성할 수 있습니다.사용 예시
다음과 같이 get 요청을 보낼 수 있습니다. 개인적으로 전체적인 코드를 보니 기존 코드와 크게 다르지 않아서 리팩토리 하기 좋을 거 같습니다.
참고 링크
Beta Was this translation helpful? Give feedback.
All reactions