Interface MessageProtocol
- All Known Implementing Classes:
SerializerMessageProtocol
public interface MessageProtocol
Consolidates the conversion of messages to/from byte buffers
and provides a rolling message buffer. ByteBuffers can be
pushed in and messages will be extracted, accumulated, and
available for retrieval. The MessageBuffers returned are generally
not thread safe and are meant to be used within a single message
processing thread. MessageProtocol implementations themselves should
be thread safe.
The specific serialization protocol used is up to the implementation.
- Author:
- Paul Speed
-
Method Summary
Modifier and TypeMethodDescriptionCreates a rolling message buffer compatible with this protocol.toByteBuffer(Message message, ByteBuffer target) Serializes a message into a byte buffer.toMessage(ByteBuffer bytes) Deserializes a message from a byte buffer.
-
Method Details
-
toByteBuffer
Serializes a message into a byte buffer.- Parameters:
message- the message to serializetarget- the optional target buffer to reuse- Returns:
- a buffer containing the serialized message
-
toMessage
Deserializes a message from a byte buffer.- Parameters:
bytes- the serialized message bytes- Returns:
- the decoded message
-
createBuffer
MessageBuffer createBuffer()Creates a rolling message buffer compatible with this protocol.- Returns:
- a new message buffer
-