docs: public int read(final MessageHandler handler, final int messageCountLimit)
      {
          int messagesRead = 0;
  
          final AtomicBuffer buffer = this.buffer;
          final int headPositionIndex = this.headPositionIndex;
          final long head = buffer.getLong(headPositionIndex);
  
          final int capacity = this.capacity;
          final int headIndex = (int)head & (capacity - 1);
          final int maxBlockLength = capacity - headIndex;
          int bytesRead = 0;
  
          try
          {
              while ((bytesRead < maxBlockLength) && (messagesRead < messageCountLimit))
              {
                  final int recordIndex = headIndex + bytesRead;
                  final int recordLength = buffer.getIntVolatile(lengthOffset(recordIndex));
                  if (recordLength <= 0)
                  {
                      break;
                  }
  
                  bytesRead += align(recordLength, ALIGNMENT);
  
                  final int messageTypeId = buffer.getInt(typeOffset(recordIndex));
                  if (PADDING_MSG_TYPE_ID == messageTypeId)
                  {
                      continue;
                  }
  
                  ++messagesRead;
                  handler.onMessage(messageTypeId, buffer, recordIndex + HEADER_LENGTH, recordLength - HEADER_LENGTH);
              }
          }
          finally
          {
              if (bytesRead != 0)
              {
                  buffer.setMemory(headIndex, bytesRead, (byte)0);
                  buffer.putLongOrdered(headPositionIndex, head + bytesRead);
              }
          }
  
          return messagesRead;
      }