You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/asciidoc/web-flux.adoc
+12-5Lines changed: 12 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -171,6 +171,12 @@ that enable the serialization of a `Flux` of bytes to and from typed objects.
171
171
The `spring-web` module adds JSON (Jackson) and XML (JAXB) implementations for use in
172
172
web applications as well as others for SSE streaming and zero-copy file transfer.
173
173
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
+
174
180
For example the request body can be one of the following way and it will be decoded
175
181
automatically in both the annotation and the functional programming models:
176
182
@@ -187,6 +193,7 @@ The response body can be one of the following:
187
193
* `Flux<Account>` -- streaming scenario, possibly SSE depending on the requested content type.
188
194
* `Observable<Account>` -- same but using RxJava `Observable` type.
189
195
* `Flowable<Account>` -- same but using RxJava 2 `Flowable` type.
196
+
* `Publisher<Account>` or `Flow.Publisher<Account>` -- any type implementing Reactive Streams `Publisher` is supported.
190
197
* `Flux<ServerSentEvent>` -- SSE streaming.
191
198
* `Mono<Void>` -- request handling completes when the `Mono` completes.
192
199
* `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.
195
202
196
203
When using stream types like `Flux` or `Observable`, the media type specified in the
197
204
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
199
206
default as following:
200
207
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
202
209
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
204
211
serialized as individual JSON object separated by new lines and explicitly flushed after
205
212
each element. The `WebClient` supports JSON stream decoding so this is a good use case
206
213
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
209
216
using by default JSON for data encoding and explicit flush after each element. This
210
217
is well suited for exposing a stream to browser clients. `WebClient` supports
0 commit comments