Skip to content

Commit 9228863

Browse files
committed
Document Reactive APIs support
1 parent 54192cf commit 9228863

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/asciidoc/web-flux.adoc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ that enable the serialization of a `Flux` of bytes to and from typed objects.
171171
The `spring-web` module adds JSON (Jackson) and XML (JAXB) implementations for use in
172172
web applications as well as others for SSE streaming and zero-copy file transfer.
173173

174+
The following Reactive APIs are supported:
175+
176+
* Reactor 3.x is supported out of the box
177+
* RxJava 2.x is supported when `io.reactivex.rxjava2:rxjava` dependency is on the classpath
178+
* RxJava 1.x is supported when both `io.reactivex:rxjava` and `io.reactivex:rxjava-reactive-streams` (https://github.com/ReactiveX/RxJavaReactiveStreams[adapter between RxJava and Reactive Streams]) dependencies are on the classpath
179+
174180
For example the request body can be one of the following way and it will be decoded
175181
automatically in both the annotation and the functional programming models:
176182

@@ -187,6 +193,7 @@ The response body can be one of the following:
187193
* `Flux<Account>` -- streaming scenario, possibly SSE depending on the requested content type.
188194
* `Observable<Account>` -- same but using RxJava `Observable` type.
189195
* `Flowable<Account>` -- same but using RxJava 2 `Flowable` type.
196+
* `Publisher<Account>` or `Flow.Publisher<Account>` -- any type implementing Reactive Streams `Publisher` is supported.
190197
* `Flux<ServerSentEvent>` -- SSE streaming.
191198
* `Mono<Void>` -- request handling completes when the `Mono` completes.
192199
* `Account` -- serialize without blocking the given Account; implies a synchronous, non-blocking controller method.
@@ -195,17 +202,17 @@ when the method returns; implies a synchronous, non-blocking controller method.
195202

196203
When using stream types like `Flux` or `Observable`, the media type specified in the
197204
request/response or at mapping/routing level is used to determine how the data should be serialized
198-
and flushed. For example a REST endpoint that returns a `Flux<User>` will be serialized by
205+
and flushed. For example a REST endpoint that returns a `Flux<Account>` will be serialized by
199206
default as following:
200207

201-
* `application/json`: a `Flux<User>` is handled as an asynchronous collection and
208+
* `application/json`: a `Flux<Account>` is handled as an asynchronous collection and
202209
serialized as a JSON array with an explicit flush when the `complete` event is emitted.
203-
* `application/stream+json`: a `Flux<User>` will be handled as a stream of `User` elements
210+
* `application/stream+json`: a `Flux<Account>` will be handled as a stream of `Account` elements
204211
serialized as individual JSON object separated by new lines and explicitly flushed after
205212
each element. The `WebClient` supports JSON stream decoding so this is a good use case
206213
for server to server use case.
207-
* `text/event-stream`: a `Flux<User>` or `Flux<ServerSentEvent<User>>` will be handled as
208-
a stream of `User` or `ServerSentEvent` elements serialized as individual SSE elements
214+
* `text/event-stream`: a `Flux<Account>` or `Flux<ServerSentEvent<Account>>` will be handled as
215+
a stream of `Account` or `ServerSentEvent` elements serialized as individual SSE elements
209216
using by default JSON for data encoding and explicit flush after each element. This
210217
is well suited for exposing a stream to browser clients. `WebClient` supports
211218
reading SSE streams as well.

0 commit comments

Comments
 (0)