Top Methods
com.mysql.cj.protocol

public Interface MessageReader<H extends MessageHeader, M extends Message>

Known Direct Implementers
com.mysql.cj.protocol.a.DebugBufferingPacketReader, com.mysql.cj.protocol.a.MultiPacketReader, com.mysql.cj.protocol.a.SimplePacketReader, com.mysql.cj.protocol.a.TimeTrackingPacketReader, com.mysql.cj.protocol.a.TracingPacketReader, com.mysql.cj.protocol.x.SyncMessageReader
Imports
java.io.IOException, java.util.Optional, com.mysql.cj.exceptions.CJOperationNotSupportedException, .ExceptionFactory

Method Summary

Modifier and TypeMethod and Description
public default byte

Returns:

number
getMessageSequence
()

Get last message sequence number, as it was stored by readHeader().

public default H

Returns:

MessageHeader of the next message
probeHeader
()

Read the next message header from server, possibly blocking indefinitely until the message is received, and cache it so that the next readHeader() return the same header.

public default M

Returns:

Message instance
probeMessage
(Optional<M>
Message object to reuse. May be ignored by implementation.
reuse
,
H
MessageHeader instance
header
)

Read message from server into to the given Message instance or into the new one if not present and cache it so that the next readMessage(Optional, MessageHeader) return the same message.

public default void
pushMessageListener(MessageListener<M> l)

Queue a MessageListener to receive messages delivered asynchronously.

public H

Returns:

MessageHeader of the next message
readHeader
()

Read the next message header from server, possibly blocking indefinitely until the message is received.

public M

Returns:

Message instance
readMessage
(Optional<M>
Message object to reuse. May be ignored by implementation.
reuse
,
H
MessageHeader instance
header
)

Read message from server into to the given Message instance or into the new one if not present.

public default M

Returns:

Message instance
readMessage
(Optional<M>
Message object to reuse. May be ignored by implementation.
reuse
,
int
Expected type of message.
expectedType
)

Read message from server into to the given Message instance or into the new one if not present.

public default void
resetMessageSequence()

Set stored message sequence number to 0.

public default void
skipPacket()

Skips the next packet, or the current one if previously probed, by reading and discarding it.

public default void
start()

Start reading messages reader from the provided channel.

public default void
stopAfterNextMessage()

Signal to the reader that it should stop reading messages after reading the next message.

public default MessageReader<H, M>

Returns:

MessageReader
undecorate
()

Return the previous MessageReader instance from the decorators chain or the current MessageReader if it is the first entry in a chain.

public default MessageReader<H, M>

Returns:

MessageReader
undecorateAll
()

Return a MessageReader instance free of decorators.

Method Detail

getMessageSequenceback to summary
public default byte getMessageSequence()

Get last message sequence number, as it was stored by readHeader().

Returns:byte

number

probeHeaderback to summary
public default H probeHeader() throws IOException

Read the next message header from server, possibly blocking indefinitely until the message is received, and cache it so that the next readHeader() return the same header.

Returns:H

MessageHeader of the next message

Exceptions
IOException:
if an error occurs
probeMessageback to summary
public default M probeMessage(Optional<M> reuse, H header) throws IOException

Read message from server into to the given Message instance or into the new one if not present and cache it so that the next readMessage(Optional, MessageHeader) return the same message. 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 parse

Parameters
reuse:Optional<M>

Message object to reuse. May be ignored by implementation.

header:H

MessageHeader instance

Returns:M

Message instance

Exceptions
IOException:
if an error occurs
pushMessageListenerback to summary
public default void pushMessageListener(MessageListener<M> l)

Queue a MessageListener to receive messages delivered asynchronously.

Parameters
l:MessageListener<M>

MessageListener

readHeaderback to summary
public H readHeader() throws IOException

Read the next message header from server, possibly blocking indefinitely until the message is received.

Returns:H

MessageHeader of the next message

Exceptions
IOException:
if an error occurs
readMessageback to summary
public M readMessage(Optional<M> reuse, H header) throws IOException

Read message from server into to the given 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 parse

Parameters
reuse:Optional<M>

Message object to reuse. May be ignored by implementation.

header:H

MessageHeader instance

Returns:M

Message instance

Exceptions
IOException:
if an error occurs
readMessageback to summary
public default M readMessage(Optional<M> reuse, int expectedType) throws IOException

Read message from server into to the given 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).

Parameters
reuse:Optional<M>

Message object to reuse. May be ignored by implementation.

expectedType:int

Expected type of message.

Returns:M

Message instance

Exceptions
IOException:
if an error occurs
resetMessageSequenceback to summary
public default void resetMessageSequence()

Set stored message sequence number to 0.

skipPacketback to summary
public default void skipPacket() throws IOException

Skips the next packet, or the current one if previously probed, by reading and discarding it.

Exceptions
IOException:
if an error occurs
startback to summary
public default void start()

Start reading messages reader from the provided channel.

stopAfterNextMessageback to summary
public default void stopAfterNextMessage()

Signal to the reader that it should stop reading messages after reading the next message.

undecorateback to summary
public default MessageReader<H, M> undecorate()

Return the previous MessageReader instance from the decorators chain or the current MessageReader if it is the first entry in a chain.

Returns:MessageReader<H, M>

MessageReader

undecorateAllback to summary
public default MessageReader<H, M> undecorateAll()

Return a MessageReader instance free of decorators.

Returns:MessageReader<H, M>

MessageReader