Package com.mysql.cj.protocol
Interface MessageSender<M extends Message>
- Type Parameters:
M
- Message type
- All Known Implementing Classes:
CompressedPacketSender
,DebugBufferingPacketSender
,SimplePacketSender
,SyncMessageSender
,TimeTrackingPacketSender
,TracingPacketSender
public interface MessageSender<M extends Message>
This interface provides a facility for sending messages to server. The destination, transmission method, etc are determined by the implementation.
-
Method Summary
Modifier and Type Method Description default void
send(byte[] message, int messageLen, byte messageSequence)
Synchronously send the message to server.default void
send(M message)
Synchronously send the message to server.default java.util.concurrent.CompletableFuture<?>
send(M message, java.util.concurrent.CompletableFuture<?> future, java.lang.Runnable callback)
Asynchronously write a message with a notification being delivered tocallback
upon completion of write of entire message.default void
setMaxAllowedPacket(int maxAllowedPacket)
Set max allowed packet size.default MessageSender<M>
undecorate()
Return the previous PacketSender instance from the decorators chain or the current PacketSender if it is the first entry in a chain.default MessageSender<M>
undecorateAll()
Return a PacketSender instance free of decorators.
-
Method Details
-
send
default void send(byte[] message, int messageLen, byte messageSequence) throws java.io.IOExceptionSynchronously send the message to server.- Parameters:
message
- byte array containing a messagemessageLen
- length of the messagemessageSequence
- message sequence index (used in a native protocol)- Throws:
java.io.IOException
- if an error occurs
-
send
Synchronously send the message to server.- Parameters:
message
-Message
instance
-
send
default java.util.concurrent.CompletableFuture<?> send(M message, java.util.concurrent.CompletableFuture<?> future, java.lang.Runnable callback)Asynchronously write a message with a notification being delivered tocallback
upon completion of write of entire message.- Parameters:
message
- message extendingMessage
future
- a Future returning operation resultcallback
- a callback to receive notification of when the message is completely written- Returns:
- result
-
setMaxAllowedPacket
default void setMaxAllowedPacket(int maxAllowedPacket)Set max allowed packet size.- Parameters:
maxAllowedPacket
- max allowed packet size
-
undecorateAll
Return a PacketSender instance free of decorators.- Returns:
MessageSender
instance
-
undecorate
Return the previous PacketSender instance from the decorators chain or the current PacketSender if it is the first entry in a chain.- Returns:
MessageSender
instance
-