WebFlux improvements
* add `BodyExtractor` support for Outbound part * add `ClientHttpResponseBodyExtractor` as identity function * add XML configuration for the Inbound part * document `BodyExtractor` and Inbound XML support Rename `replyToFlux` property to the `replyPayloadToFlux` Doc Polishing
This commit is contained in:
committed by
Gary Russell
parent
1e1346dc94
commit
b5ec98f025
@@ -100,9 +100,13 @@ Together with the `ReactiveChannel` as an `outputChannel`, the `Mono<ClientRespo
|
||||
Otherwise, it is treated as an `async` mode and the `Mono` response is adapted to an `SettableListenableFuture` for an asynchronous reply from the `WebFluxRequestExecutingMessageHandler`.
|
||||
The target payload of the output message depends on the `WebFluxRequestExecutingMessageHandler` configuration.
|
||||
The `setExpectedResponseType(Class<?>)` or `setExpectedResponseTypeExpression(Expression)` identifies the target type of the response body element conversion.
|
||||
If `replyToFlux` is set to `true`, the response body is converted to a `Flux` with the provided `expectedResponseType` for each element and this `Flux` is sent as the payload downstream.
|
||||
If the `replyPayloadToFlux` is set to `true`, the response body is converted to a `Flux` with the provided `expectedResponseType` for each element and this `Flux` is sent as the payload downstream.
|
||||
A <<splitter,splitter>> afterwards can be used to iterate over this `Flux` in a reactive manner.
|
||||
|
||||
In addition a `BodyExtractor<?, ClientHttpResponse>` can be injected into the `WebFluxRequestExecutingMessageHandler` instead of `expectedResponseType` and `replyPayloadToFlux` properties.
|
||||
It can be used for low-level access to the `ClientHttpResponse` and more control over body and HTTP headers conversion.
|
||||
The `ClientHttpResponseBodyExtractor` is provided out-of-the-box as identity function to produce downstream the whole `ClientHttpResponse` and any other possible custom logic.
|
||||
|
||||
Also see <<http-outbound>> for more possible configuration options.
|
||||
|
||||
[[webflux-namespace]]
|
||||
@@ -133,6 +137,48 @@ To include it in your configuration, simply provide the following namespace decl
|
||||
|
||||
==== Inbound
|
||||
|
||||
To configure Spring Integration WebFlux via XML you may use appropriate components from the mentioned `int-webflux` namespace - `inbound-channel-adapter` or `inbound-gateway` according request/response requirements respectively:
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<inbound-channel-adapter id="reactiveFullConfig" channel="requests"
|
||||
path="test1"
|
||||
auto-startup="false"
|
||||
phase="101"
|
||||
request-payload-type="byte[]"
|
||||
error-channel="errorChannel"
|
||||
payload-expression="payload"
|
||||
supported-methods="PUT"
|
||||
status-code-expression="'202'"
|
||||
header-mapper="headerMapper"
|
||||
codec-configurer="codecConfigurer"
|
||||
reactive-adapter-registry="reactiveAdapterRegistry"
|
||||
requested-content-type-resolver="requestedContentTypeResolver">
|
||||
<request-mapping headers="foo"/>
|
||||
<cross-origin origin="foo"
|
||||
method="PUT"/>
|
||||
<header name="foo" expression="'foo'"/>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
<inbound-gateway id="reactiveFullConfig" request-channel="requests"
|
||||
path="test1"
|
||||
auto-startup="false"
|
||||
phase="101"
|
||||
request-payload-type="byte[]"
|
||||
error-channel="errorChannel"
|
||||
payload-expression="payload"
|
||||
supported-methods="PUT"
|
||||
reply-timeout-status-code-expression="'504'"
|
||||
header-mapper="headerMapper"
|
||||
codec-configurer="codecConfigurer"
|
||||
reactive-adapter-registry="reactiveAdapterRegistry"
|
||||
requested-content-type-resolver="requestedContentTypeResolver">
|
||||
<request-mapping headers="foo"/>
|
||||
<cross-origin origin="foo"
|
||||
method="PUT"/>
|
||||
<header name="foo" expression="'foo'"/>
|
||||
</inbound-gateway>
|
||||
----
|
||||
|
||||
==== Outbound
|
||||
|
||||
|
||||
Reference in New Issue
Block a user