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 void
pushMessageListener(MessageListener<XMessage> listener)
Queue aMessageListener
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 givenMessage
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 givenMessage
instance 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, wait
Methods inherited from interface com.mysql.cj.protocol.MessageReader
getMessageSequence, resetMessageSequence, start, stopAfterNextMessage, undecorate, undecorateAll
-
Constructor Details
-
Method Details
-
readHeader
Description copied from interface:MessageReader
Read the next message header from server, possibly blocking indefinitely until the message is received.- Specified by:
readHeader
in interfaceMessageReader<XMessageHeader,XMessage>
- Returns:
MessageHeader
of 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:MessageReader
Read message from server into to the givenMessage
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 anIOException
during read or parse- Specified by:
readMessage
in interfaceMessageReader<XMessageHeader,XMessage>
- Parameters:
reuse
-Message
object to reuse. May be ignored by implementation.hdr
-MessageHeader
instance- Returns:
Message
instance- 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:MessageReader
Read message from server into to the givenMessage
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).- Specified by:
readMessage
in interfaceMessageReader<XMessageHeader,XMessage>
- Parameters:
reuse
-Message
object to reuse. May be ignored by implementation.expectedType
- Expected type of message.- Returns:
Message
instance- Throws:
java.io.IOException
- if an error occurs
-
pushMessageListener
Description copied from interface:MessageReader
Queue aMessageListener
to receive messages delivered asynchronously.- Specified by:
pushMessageListener
in interfaceMessageReader<XMessageHeader,XMessage>
- Parameters:
listener
-MessageListener
-