Split streaming API from `WebClient`
See original GitHub issueIf a user receives a fully aggregated HTTP response, he or she should call aggregate():
WebClient client = ...;
CompleteFuture<AggregateHttpResponse> response = client.get("/some/path").aggregate();
It could be boilerplate to call aggregate() every time because most REST API returns
a unary HTTP response. I think we can improve this API design by splitting WebClient
and StreamWebClient. The original idea was suggested by @trustin.
WebClient client = ...;
// Returns an aggregated response directly
CompleteFuture<AggregatedHttpResponse> response = client.get("/some/path");
// Switch to a streaming client.
StreamingWebClient streamingClient = client.streaming();
// Returns an HttpResponse that can be subscribed by a Reactive Streams `Subscriber`
HttpResponse response = streamingClient.get("/some/path");
Furthermore, we can also provide a blocking WebClient for blocking services and tests.
WebClient client = ...;
// Switch to a streaming client.
BlockingWebClient blockingClient = client.blocking();
// Wait for an aggregated response until fully received.
AggregatedHttpResponse response = blockingClient.get("/some/path");
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Splitting a WebClient Post of a Streaming Flux into JSON Arrays
How do I POST in chunks of arrays? Use one of the variants of Flux.window to split the main flux into windowed fluxes,...
Read more >Split WebClient into blocking / async versions? #2364 - GitHub
Streaming WebClient , always returns HttpResponse. I guess users either always use blocking, or always use async, so it can be annoying to ......
Read more >Real Time Event Streaming using Spring WebFlux - Medium
Introduction. In this article, we'll explore Spring's new WebFlux Framework and build a real-time event streaming API using it.
Read more >Simultaneous Spring WebClient Calls - Baeldung
Learn how to make simultaneous HTTP requests using The Spring WebClient.
Read more >13 Using WebClient to make API calls - YouTube
In this video, we'll switch to using WebClient for making API calls. We'll explore how WebClient uses reactive programming constructs for ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Sounds very familiar 😛 #2364
Don’t think it needs to wait for 2.0.0, can leave
WebClientas is and convert it to the wrappers as per @trustin’s suggestionAnother one or two years sounds better 😃 It is also a good reason to go with your proposed approach from #2364 I think as it does sound reasonable far off then (good thing).