본문 바로가기

Web/spring

[Spring framework Web MVC docs] 2. REST Clients

728x90

https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#webmvc-client

 

Web on Servlet Stack

Spring Web MVC is the original web framework built on the Servlet API and has been included in the Spring Framework from the very beginning. The formal name, "Spring Web MVC," comes from the name of its source module (spring-webmvc), but it is more commonl

docs.spring.io

 

틀린 해석이나 내용이 있다면 알려주세요, 감사합니다 🌱

 


client-side access to REST endpoints

 

 

 

2.1. RestTemplate

RestTemplate 는 HTTP request 를 수행하는 synchronous(동기식) client 이다

기본 HTTP client library를 통해 간단한 template method API를 보여주는 Spring REST Client이다

 

 

비동기식은 web-reactive 문서를 살펴볼 것

https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html#webflux-client

 

Web on Reactive Stack

The original web framework included in the Spring Framework, Spring Web MVC, was purpose-built for the Servlet API and Servlet containers. The reactive-stack web framework, Spring WebFlux, was added later in version 5.0. It is fully non-blocking, supports

docs.spring.io

 

 

다음에 한번 다뤄볼 REST endpoint

https://docs.spring.io/spring-framework/docs/current/reference/html/integration.html#rest-client-access

 

Integration

The Spring Framework provides abstractions for the asynchronous execution and scheduling of tasks with the TaskExecutor and TaskScheduler interfaces, respectively. Spring also features implementations of those interfaces that support thread pools or delega

docs.spring.io

 

 

2.2. WebClient

WebClient 는 HTTP request 를 수행하기 위한 non-blocking 반응형 클라이언트이다

RestTemplate Streming 시나리오 뿐만 아니라 동기식 비동기식 모두를 지원한다

 

RestTemplate과 달리 여러가지를 지원한다

 

  • Non-blocking I/O.
  • Reactive Streams back pressure.
  • High concurrency with fewer hardware resources.
  • Functional-style, fluent API that takes advantage of Java 8 lambdas.
  • Synchronous and asynchronous interactions.
  • Streaming up to or streaming down from a server.

 

 

2.3. HTTP Interface

Spring Frameworks를 사용하면 HTTP 교환 방법을 사용하여 HTTP service를 Java interface로 정의할 수 있다

그러면 이 인터페이스를 구현하고, exchanges 를 수행하는 proxy를 생성할 수 있다

HTTP 원격 액세스를 단순화하고, 동기식 또는 반응식과 같은 API 스타일을 선택할 수 있는 유연성을 제공한다

 

 

 

 

728x90