Skip to content

Commit 314f3fc

Browse files
committed
Summary of client-side REST options in MVC section
1 parent c3cf084 commit 314f3fc

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

src/docs/asciidoc/integration.adoc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -948,14 +948,16 @@ plugging in third-party or custom solutions here.
948948
[[rest-client-access]]
949949
=== Accessing REST endpoints
950950

951-
The Spring Framework offers two choices for client-side access to REST endpoints:
951+
The Spring Framework has two choices for client-side access to REST endpoints:
952952

953953
* <<rest-resttemplate>> -- the original Spring REST client with an API similar to other
954-
template classes in Spring, such as `JdbcTemplate`, `JmsTemplate` and others. The
955-
`RestTemplate` is built for synchronous use with the blocking I/O.
954+
template classes in Spring such as `JdbcTemplate`, `JmsTemplate` and others.
955+
`RestTemplate` has a synchronous API and relies on blocking I/O which is okay for
956+
client scenarios with low concurrency.
956957
* <<web-reactive.adoc#webflux-client,WebClient>> -- reactive client with a functional,
957-
fluent API from the `spring-webflux` module. It is built on a non-blocking foundation
958-
for async and sync scenarios and supports Reactive Streams back pressure.
958+
fluent API from the `spring-webflux` module. It relies on non-blocking I/O which allows it
959+
to support high concurrency more efficiently (i.e. using a small number of threads) than the
960+
`RestTemplate`. `WebClient` is a natural fit for streaming scenarios.
959961

960962

961963
[[rest-resttemplate]]
@@ -966,11 +968,6 @@ that correspond to each of the six main HTTP methods that make invoking many RES
966968
services a one-liner and enforce REST best practices.
967969

968970

969-
[NOTE]
970-
====
971-
RestTemplate has an asynchronous counter-part: see <<rest-async-resttemplate>>.
972-
====
973-
974971
[[rest-overview-of-resttemplate-methods-tbl]]
975972
.Overview of RestTemplate methods
976973
[cols="1,3"]

src/docs/asciidoc/web.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ For reactive stack, web applications, go to <<web-reactive.adoc#spring-web-react
1313

1414
include::web/webmvc.adoc[leveloffset=+1]
1515

16+
include::web/webmvc-client.adoc[leveloffset=+1]
17+
1618
include::web/webmvc-test.adoc[leveloffset=+1]
1719

1820
include::web/websocket.adoc[leveloffset=+1]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[[webmvc-client]]
2+
= REST Clients
3+
4+
This section describes options for client-side access to REST endpoints.
5+
6+
[[webmvc-resttemplate]]
7+
== RestTemplate
8+
9+
`RestTemplate` is the original Spring REST client that follows a similar approach to other
10+
template classes in the Spring Framework (e.g. `JdbcTemplate`, `JmsTemplate`, etc.) by
11+
providing a list of parameterizable methods to perform HTTP requests.
12+
13+
`RestTemplate` has a synchronous API and relies on blocking I/O. This is okay for
14+
client scenarios with low concurrency. In a server environment or when orchestrating a
15+
sequence of remote calls, prefer using the `WebClient` which provides a more efficient
16+
execution model including seamless support for streaming.
17+
18+
See <<integration.adoc#rest-client-access,RestTemplate>> for more details on using the
19+
`RestTemplate`.
20+
21+
22+
[[webmvc-webclient]]
23+
== WebClient
24+
25+
`WebClient` is a reactive client that provides an alternative to the `RestTemplate`. It
26+
exposes a functional, fluent API and relies on non-blocking I/O which allows it to support
27+
high concurrency more efficiently (i.e. using a small number of threads) than the
28+
`RestTemplate`. `WebClient` is a natural fit for streaming scenarios.
29+
30+
See <<web-reactive.adoc#webflux-client,WebClient>> for more details on using the `WebClient`.

0 commit comments

Comments
 (0)