The current milestone (M4) documentation shows and example about how to retrieve a Mono
using WebClient
:
WebClient webClient = WebClient.create(new ReactorClientHttpConnector());
ClientRequest<Void> request = ClientRequest.GET("http://example.com/accounts/{id}", 1L)
.accept(MediaType.APPLICATION_JSON).build();
Mono<Account> account = this.webClient
.exchange(request)
.then(response -> response.body(toMono(Account.class)));
How can we get streamed data (from a service that returns text/event-stream
) into a Flux using WebClient? Does it support automatic Jackson conversion?.
This is how I did it in a previous milestone, but the API has changed and can't find how to do it anymore:
final ClientRequest<Void> request = ClientRequest.GET(url)
.accept(MediaType.TEXT_EVENT_STREAM).build();
Flux<Alert> response = webClient.retrieveFlux(request, Alert.class)
This is how you can achieve the same thing with the new API: