WebFlux.outboundGateway has no way of producing Flux<Anything> #2300
Description
In WebFluxRequestExecutingMessageHandler
, I see the following:
if (expectedResponseType instanceof ParameterizedTypeReference<?>) {
bodyMono = response.body(BodyExtractors.toMono((ParameterizedTypeReference<?>) expectedResponseType));
}
else if (expectedResponseType != null) {
bodyMono = response.body(BodyExtractors.toMono((Class<?>) expectedResponseType));
}
What I'm expecting as response is Flux<DataBuffer>
that I can do some processing on before sending to an output channel. However, the above code always forces the body to be converted to Mono
.
The documentation for webflux support merely regurgitates what's in the code.
The WebClient exchange() operation returns a Mono which is mapped to the AbstractIntegrationMessageBuilder reactive support (using Mono.map()) as the output from the WebFluxRequestExecutingMessageHandler. Together with the ReactiveChannel as an outputChannel, the Mono evaluation is deferred until a downstream subscription is made. Otherwise, it is treated as an async mode and the Mono response is adapted to an SettableListenableFuture for an asynchronous reply from the WebFluxRequestExecutingMessageHandler.
It'd be nice to also see some examples for how to get a Flux<UserDataType>
, Flux<DataBuffer>
, Mono<ClientResponse>
etc. As with RestTemplate
, where I've the option to get the ResponseEntity
if I want to do the processing myself, I should also be able to get Mono<ClientResponse>
should I so choose.