public class ServerSentEventHttpMessageReader extends Object implements HttpMessageReader<Object>
ServerSentEvents and also plain
Objects which is the same as an ServerSentEvent with data only.| Constructor and Description |
|---|
ServerSentEventHttpMessageReader()
Constructor without a
Decoder. |
ServerSentEventHttpMessageReader(Decoder<?> decoder)
Constructor with JSON
Decoder for decoding to Objects. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRead(ResolvableType elementType,
MediaType mediaType)
Whether the given object type is supported by this reader.
|
Decoder<?> |
getDecoder()
Return the configured
Decoder. |
int |
getMaxInMemorySize()
Return the
configured byte count limit. |
List<MediaType> |
getReadableMediaTypes()
Return the list of media types supported by this reader.
|
reactor.core.publisher.Flux<Object> |
read(ResolvableType elementType,
ReactiveHttpInputMessage message,
Map<String,Object> hints)
Read from the input message and decode to a stream of objects.
|
reactor.core.publisher.Mono<Object> |
readMono(ResolvableType elementType,
ReactiveHttpInputMessage message,
Map<String,Object> hints)
Read from the input message and decode to a single object.
|
void |
setMaxInMemorySize(int byteCount)
Configure a limit on the maximum number of bytes per SSE event which are
buffered before the event is parsed.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetReadableMediaTypes, read, readMonopublic ServerSentEventHttpMessageReader()
Decoder. In this mode only String
is supported as the data of an event.public void setMaxInMemorySize(int byteCount)
Note that the data decoder, if provided, must
also be customized accordingly to raise the limit if necessary in order
to be able to parse the data portion of the event.
By default this is set to 256K.
byteCount - the max number of bytes to buffer, or -1 for unlimitedpublic int getMaxInMemorySize()
configured byte count limit.public List<MediaType> getReadableMediaTypes()
HttpMessageReadercanWrite(elementType, null). The list may also exclude media types
supported only for a specific element type. Alternatively, use
HttpMessageReader.getReadableMediaTypes(ResolvableType) for a more precise list.getReadableMediaTypes in interface HttpMessageReader<Object>public boolean canRead(ResolvableType elementType, @Nullable MediaType mediaType)
HttpMessageReadercanRead in interface HttpMessageReader<Object>elementType - the type of object to checkmediaType - the media type for the read (possibly null)true if readable, false otherwisepublic reactor.core.publisher.Flux<Object> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)
HttpMessageReaderread in interface HttpMessageReader<Object>elementType - the type of objects in the stream which must have been
previously checked via HttpMessageReader.canRead(ResolvableType, MediaType)message - the message to read fromhints - additional information about how to read and decode the inputpublic reactor.core.publisher.Mono<Object> readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)
HttpMessageReaderreadMono in interface HttpMessageReader<Object>elementType - the type of objects in the stream which must have been
previously checked via HttpMessageReader.canRead(ResolvableType, MediaType)message - the message to read fromhints - additional information about how to read and decode the input