Encoder that writes com.google.protobuf.Message s
using Google Protocol Buffers.
Flux are serialized using delimited Protobuf messages with the size of each message specified before the message itself. Single values are serialized using regular Protobuf message format (without the size prepended before the message).
To generate Message Java classes, you need to install the protoc binary.
This encoder requires Protobuf 3 or higher, and supports
"application/x-protobuf" and "application/octet-stream" with the official
"com.google.protobuf:protobuf-java" library.
ProtobufDecoder
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | canEncode(ResolvableType
the type of elements in the source stream elementType, MimeType the MIME type for the output stream
(can be mimeType)null if not specified)Implements org. Whether the encoder supports the given source element type and the MIME type for the output stream. |
| public Flux | encode(Publisher<? extends Message>
the input stream of Objects to encode. If the input should be
encoded as a single value rather than as a stream of elements, an instance of
inputStream, DataBufferFactory Mono should be used.for creating output stream bufferFactory, ResolvableType DataBuffer'sthe expected type of elements in the input stream;
this type must have been previously passed to the elementType, MimeType canEncode
method and it must have returned true.the MIME type for the output content (optional) mimeType, Map<String, Object> additional information about how to encode hints)Implements org. Encode a stream of Objects of type |
| public DataBuffer | encodeValue(Message
the value to be encoded message, DataBufferFactory for creating the output bufferFactory, ResolvableType DataBufferthe type for the value being encoded valueType, MimeType the MIME type for the output content (optional) mimeType, Map<String, Object> additional information about how to encode hints)Overrides default org. Encode an Object of type T to a data buffer. |
| private DataBuffer | |
| public List | getEncodableMimeTypes()
Implements org. Return the list of MIME types supported by this Encoder. |
| public List | getStreamingMediaTypes()
Implements org. Return "streaming" media types for which flushing should be performed automatically vs at the end of the input stream. |
| streamingMediaTypes | back to summary |
|---|---|
| private static final List<MediaType> streamingMediaTypes | |
| ProtobufEncoder | back to summary |
|---|---|
| public ProtobufEncoder() | |
| canEncode | back to summary |
|---|---|
| public boolean canEncode(ResolvableType elementType, MimeType mimeType) Implements org. Doc from org. Whether the encoder supports the given source element type and the MIME type for the output stream.
| |
| encode | back to summary |
|---|---|
| public Flux Implements org. Doc from org. Encode a stream of Objects of type
| |
| encodeValue | back to summary |
|---|---|
| public DataBuffer encodeValue(Message message, DataBufferFactory bufferFactory, ResolvableType valueType, MimeType mimeType, Map<String, Object> hints) Overrides default org. Doc from org. Encode an Object of type T to a data buffer. This is useful for scenarios, that distinct messages (or events) are encoded and handled individually, in fully aggregated form. By default this method raises
| |
| encodeValue | back to summary |
|---|---|
| private DataBuffer encodeValue(Message message, DataBufferFactory bufferFactory, boolean delimited) | |
| getEncodableMimeTypes | back to summary |
|---|---|
| public List Implements org. Doc from org. Return the list of MIME types supported by this Encoder. The list may not
apply to every possible target element type and calls to this method should
typically be guarded via | |
| getStreamingMediaTypes | back to summary |
|---|---|
| public List Implements org. Doc from org. Return "streaming" media types for which flushing should be performed automatically vs at the end of the input stream.
| |