|
|
|
@ -755,9 +755,9 @@ into ``TokenBuffer``'s each representing a JSON object. |
|
|
|
* When decoding to a single-value publisher (e.g. `Mono`), there is one `TokenBuffer`. |
|
|
|
* When decoding to a single-value publisher (e.g. `Mono`), there is one `TokenBuffer`. |
|
|
|
* When decoding to a multi-value publisher (e.g. `Flux`), each `TokenBuffer` is passed to |
|
|
|
* When decoding to a multi-value publisher (e.g. `Flux`), each `TokenBuffer` is passed to |
|
|
|
the `ObjectMapper` as soon as enough bytes are received for a fully formed object. The |
|
|
|
the `ObjectMapper` as soon as enough bytes are received for a fully formed object. The |
|
|
|
input content can be a JSON array, or |
|
|
|
input content can be a JSON array, or any |
|
|
|
https://en.wikipedia.org/wiki/JSON_streaming[line-delimited JSON] if the content-type is |
|
|
|
https://en.wikipedia.org/wiki/JSON_streaming[line-delimited JSON] format such as NDJSON, |
|
|
|
`application/stream+json`. |
|
|
|
JSON Lines, or JSON Text Sequences. |
|
|
|
|
|
|
|
|
|
|
|
The `Jackson2Encoder` works as follows: |
|
|
|
The `Jackson2Encoder` works as follows: |
|
|
|
|
|
|
|
|
|
|
|
@ -766,9 +766,10 @@ The `Jackson2Encoder` works as follows: |
|
|
|
* For a multi-value publisher with `application/json`, by default collect the values with |
|
|
|
* For a multi-value publisher with `application/json`, by default collect the values with |
|
|
|
`Flux#collectToList()` and then serialize the resulting collection. |
|
|
|
`Flux#collectToList()` and then serialize the resulting collection. |
|
|
|
* For a multi-value publisher with a streaming media type such as |
|
|
|
* For a multi-value publisher with a streaming media type such as |
|
|
|
`application/stream+json` or `application/stream+x-jackson-smile`, encode, write, and |
|
|
|
`application/x-ndjson` or `application/stream+x-jackson-smile`, encode, write, and |
|
|
|
flush each value individually using a |
|
|
|
flush each value individually using a |
|
|
|
https://en.wikipedia.org/wiki/JSON_streaming[line-delimited JSON] format. |
|
|
|
https://en.wikipedia.org/wiki/JSON_streaming[line-delimited JSON] format. Other |
|
|
|
|
|
|
|
streaming media types may be registered with the encoder. |
|
|
|
* For SSE the `Jackson2Encoder` is invoked per event and the output is flushed to ensure |
|
|
|
* For SSE the `Jackson2Encoder` is invoked per event and the output is flushed to ensure |
|
|
|
delivery without delay. |
|
|
|
delivery without delay. |
|
|
|
|
|
|
|
|
|
|
|
@ -852,7 +853,7 @@ To configure all three in WebFlux, you'll need to supply a pre-configured instan |
|
|
|
[.small]#<<web.adoc#mvc-ann-async-http-streaming, Web MVC>># |
|
|
|
[.small]#<<web.adoc#mvc-ann-async-http-streaming, Web MVC>># |
|
|
|
|
|
|
|
|
|
|
|
When streaming to the HTTP response (for example, `text/event-stream`, |
|
|
|
When streaming to the HTTP response (for example, `text/event-stream`, |
|
|
|
`application/stream+json`), it is important to send data periodically, in order to |
|
|
|
`application/x-ndjson`), it is important to send data periodically, in order to |
|
|
|
reliably detect a disconnected client sooner rather than later. Such a send could be a |
|
|
|
reliably detect a disconnected client sooner rather than later. Such a send could be a |
|
|
|
comment-only, empty SSE event or any other "no-op" data that would effectively serve as |
|
|
|
comment-only, empty SSE event or any other "no-op" data that would effectively serve as |
|
|
|
a heartbeat. |
|
|
|
a heartbeat. |
|
|
|
|