Package com.mysql.cj.protocol.x
Class SyncMessageReader
java.lang.Object
com.mysql.cj.protocol.x.SyncMessageReader
- All Implemented Interfaces:
MessageReader<XMessageHeader,XMessage>
public class SyncMessageReader extends java.lang.Object implements MessageReader<XMessageHeader,XMessage>
Synchronous-only implementation of
MessageReader. This implementation wraps a InputStream.-
Constructor Summary
Constructors Constructor Description SyncMessageReader(FullReadInputStream inputStream) -
Method Summary
Modifier and Type Method Description voidpushMessageListener(MessageListener<XMessage> listener)Queue aMessageListenerto receive messages delivered asynchronously.XMessageHeaderreadHeader()Read the next message header from server, possibly blocking indefinitely until the message is received.XMessagereadMessage(java.util.Optional<XMessage> reuse, int expectedType)Read message from server into to the givenMessageinstance or into the new one if not present.XMessagereadMessage(java.util.Optional<XMessage> reuse, XMessageHeader hdr)Read message from server into to the givenMessageinstance or into the new one if not present.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.mysql.cj.protocol.MessageReader
getMessageSequence, resetMessageSequence, start, stopAfterNextMessage, undecorate, undecorateAll
-
Constructor Details
-
Method Details
-
readHeader
Description copied from interface:MessageReaderRead the next message header from server, possibly blocking indefinitely until the message is received.- Specified by:
readHeaderin interfaceMessageReader<XMessageHeader,XMessage>- Returns:
MessageHeaderof the next message- Throws:
java.io.IOException- if an error occurs
-
readMessage
public XMessage readMessage(java.util.Optional<XMessage> reuse, XMessageHeader hdr) throws java.io.IOExceptionDescription copied from interface:MessageReaderRead message from server into to the givenMessageinstance 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 anIOExceptionduring read or parse- Specified by:
readMessagein interfaceMessageReader<XMessageHeader,XMessage>- Parameters:
reuse-Messageobject to reuse. May be ignored by implementation.hdr-MessageHeaderinstance- Returns:
Messageinstance- Throws:
java.io.IOException- if an error occurs
-
readMessage
public XMessage readMessage(java.util.Optional<XMessage> reuse, int expectedType) throws java.io.IOExceptionDescription copied from interface:MessageReaderRead message from server into to the givenMessageinstance 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).- Specified by:
readMessagein interfaceMessageReader<XMessageHeader,XMessage>- Parameters:
reuse-Messageobject to reuse. May be ignored by implementation.expectedType- Expected type of message.- Returns:
Messageinstance- Throws:
java.io.IOException- if an error occurs
-
pushMessageListener
Description copied from interface:MessageReaderQueue aMessageListenerto receive messages delivered asynchronously.- Specified by:
pushMessageListenerin interfaceMessageReader<XMessageHeader,XMessage>- Parameters:
listener-MessageListener
-