public class SyncMessageReader extends java.lang.Object implements MessageReader<XMessageHeader,XMessage>
MessageReader
. This implementation wraps a InputStream
.Constructor and Description |
---|
SyncMessageReader(FullReadInputStream inputStream) |
Modifier and Type | Method and Description |
---|---|
void |
pushMessageListener(MessageListener<XMessage> listener)
Queue a
MessageListener to receive messages delivered asynchronously. |
XMessageHeader |
readHeader()
Read the next message header from server, possibly blocking indefinitely until the message is received.
|
XMessage |
readMessage(java.util.Optional<XMessage> reuse,
int expectedType)
Read message from server into to the given
Message instance or into the new one if not present. |
XMessage |
readMessage(java.util.Optional<XMessage> reuse,
XMessageHeader hdr)
Read message from server into to the given
Message instance or into the new one if not present. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMessageSequence, resetMessageSequence, start, stopAfterNextMessage, undecorate, undecorateAll
public SyncMessageReader(FullReadInputStream inputStream)
public XMessageHeader readHeader() throws java.io.IOException
MessageReader
readHeader
in interface MessageReader<XMessageHeader,XMessage>
MessageHeader
of the next messagejava.io.IOException
- if an error occurspublic XMessage readMessage(java.util.Optional<XMessage> reuse, XMessageHeader hdr) throws java.io.IOException
MessageReader
Message
instance or into the new one if not present.
For asynchronous channel it synchronously reads the next message in the stream, blocking until the message is read fully.
Could throw CJCommunicationsException wrapping an IOException
during read or parsereadMessage
in interface MessageReader<XMessageHeader,XMessage>
reuse
- Message
object to reuse. May be ignored by implementation.hdr
- MessageHeader
instanceMessage
instancejava.io.IOException
- if an error occurspublic XMessage readMessage(java.util.Optional<XMessage> reuse, int expectedType) throws java.io.IOException
MessageReader
Message
instance or into the new one if not present.
For asynchronous channel it synchronously reads the next message in the stream, blocking until the message is read fully.
Could throw WrongArgumentException if the expected message type is not the next message (exception will be thrown in *caller* context).readMessage
in interface MessageReader<XMessageHeader,XMessage>
reuse
- Message
object to reuse. May be ignored by implementation.expectedType
- Expected type of message.Message
instancejava.io.IOException
- if an error occurspublic void pushMessageListener(MessageListener<XMessage> listener)
MessageReader
MessageListener
to receive messages delivered asynchronously.pushMessageListener
in interface MessageReader<XMessageHeader,XMessage>
listener
- MessageListener