Class GreedyMessageBuffer

All Implemented Interfaces:

public class GreedyMessageBuffer extends Object implements MessageBuffer
A MessageBuffer implementation that will aggressively create all messages as byte data comes in. In other words, if there are four messages in the ByteBuffer passed to addBuffer() then all of the messages will be deserialized during that call and queued up for later return. The downside is that, if any of those messages was going to alter the MessageProtocol serialization behavior in a way that affects later messages, then problems occur when those messages are all in one block.
  • Constructor Details

    • GreedyMessageBuffer

      public GreedyMessageBuffer(MessageProtocol protocol)
  • Method Details

    • pollMessage

      public Message pollMessage()
      Returns the next message in the buffer or null if there are no more messages in the buffer.
      Specified by:
      pollMessage in interface MessageBuffer
    • hasMessages

      public boolean hasMessages()
      Returns true if there is a message waiting in the buffer.
      Specified by:
      hasMessages in interface MessageBuffer
    • addBytes

      public boolean addBytes(ByteBuffer buffer)
      Adds byte data to the message buffer. Returns true if there is a message waiting after this call.
      Specified by:
      addBytes in interface MessageBuffer