Support Protobuf serialization in WebFlux

This commit introduces Protobuf support in WebFlux via dedicated
codecs.

Flux<Message> are serialized/deserialized using delimited Protobuf
messages with the size of each message specified before the message
itself. In that case, a "delimited=true" parameter is added to the
content type.

Mono<Message> are expected to use regular Protobuf message
format (without the size prepended before the message).

Related HttpMessageReader/Writer are automatically registered when the
"com.google.protobuf:protobuf-java" library is detected in the classpath,
and can be customized easily if needed via CodecConfigurer, for example
to specify protocol extensions via the ExtensionRegistry based
constructors.

Both "application/x-protobuf" and "application/octet-stream" mime types
are supported.

Issue: SPR-15776
This commit is contained in:
sdeleuze
2018-03-19 18:16:46 +01:00
committed by Sebastien Deleuze
parent 4475c67ba8
commit 36a07aa897
23 changed files with 2225 additions and 18 deletions

View File

@@ -661,8 +661,8 @@ use in an application.
The `spring-core` module has encoders and decoders for `byte[]`, `ByteBuffer`, `DataBuffer`,
`Resource`, and `String`. The `spring-web` module adds encoders and decoders for Jackson
JSON, Jackson Smile, JAXB2, along with other web-specific HTTP message readers and writers
for form data, multipart requests, and server-sent events.
JSON, Jackson Smile, JAXB2, Protocol Buffers, along with other web-specific HTTP message
readers and writers for form data, multipart requests, and server-sent events.
[[webflux-codecs-jackson]]