buffer.writeBytes((ChannelBuffer) e.getMessage());
while (true) {
if (dataRecordLength != -1 && buffer.readableBytes() >= dataRecordLength) {
ChannelBuffer channelBuffer = buffer.readBytes(dataRecordLength);
dataRecordLength = -1;
super.messageReceived(ctx, new UpstreamMessageEvent(e.getChannel(), channelBuffer, e.getRemoteAddress()));
} else if (dataRecordLength == -1 && buffer.readableBytes() >= Ints.BYTES) {
//We want to pass both the length bytes and the data bytes and so using getBytes so that readerIndex
//is not changed.
buffer.getBytes(buffer.readerIndex(), lengthBytes, 0, Ints.BYTES);
//Length Data is encoded as an Integer in Big Endian Format.