public interface Stream
An implementation doesn't need to be thread-safe. All methods are expected to execute quickly.
Modifier and Type | Method and Description |
---|---|
void |
flush()
Flushes any internally buffered messages to the remote end-point.
|
boolean |
isReady()
If
true , indicates that the transport is capable of sending additional messages without
requiring excessive buffering internally. |
void |
request(int numMessages)
Requests up to the given number of messages from the call to be delivered via
StreamListener.messagesAvailable(StreamListener.MessageProducer) . |
void |
setCompressor(Compressor compressor)
Sets the compressor on the framer.
|
void |
setMessageCompression(boolean enable)
Enables per-message compression, if an encoding type has been negotiated.
|
void |
writeMessage(InputStream message)
Writes a message payload to the remote end-point.
|
void request(int numMessages)
StreamListener.messagesAvailable(StreamListener.MessageProducer)
. No additional
messages will be delivered. If the stream has a start()
method, it must be called
before requesting messages.numMessages
- the requested number of messages to be delivered to the listener.void writeMessage(InputStream message)
KnownLength
to improve efficiency. This method will always return immediately
and will not wait for the write to complete. If the stream has a start()
method, it
must be called before writing any messages.
It is recommended that the caller consult isReady()
before calling this method to
avoid excessive buffering in the transport.
This method takes ownership of the InputStream, and implementations are responsible for
calling InputStream.close()
.
message
- stream containing the serialized message to be sentvoid flush()
boolean isReady()
true
, indicates that the transport is capable of sending additional messages without
requiring excessive buffering internally. Otherwise, StreamListener.onReady()
will be
called when it turns true
.
This is just a suggestion and the application is free to ignore it, however doing so may result in excessive buffering within the transport.
void setCompressor(Compressor compressor)
compressor
- the compressor to usevoid setMessageCompression(boolean enable)
Copyright © 2019. All rights reserved.