public static int read(final AtomicBuffer buffer, final EntryConsumer entryConsumer)
    {
        final int capacity = buffer.capacity();

        int recordsRead = 0;
        int offset = 0;

        while (offset < capacity)
        {
            final long observationCount = buffer.getLongVolatile(offset + OBSERVATION_COUNT_OFFSET);
            if (observationCount <= 0)
            {
                break;
            }

            ++recordsRead;

            final String channel = buffer.getStringAscii(offset + CHANNEL_OFFSET);
            final String source = buffer.getStringAscii(
                offset + CHANNEL_OFFSET + BitUtil.align(SIZE_OF_INT + channel.length(), SIZE_OF_INT));

            entryConsumer.accept(
                observationCount,
                buffer.getLongVolatile(offset + TOTAL_BYTES_LOST_OFFSET),
                buffer.getLong(offset + FIRST_OBSERVATION_OFFSET),
                buffer.getLongVolatile(offset + LAST_OBSERVATION_OFFSET),
                buffer.getInt(offset + SESSION_ID_OFFSET),
                buffer.getInt(offset + STREAM_ID_OFFSET),
                channel,
                source);

            final int recordLength =
                CHANNEL_OFFSET +
                BitUtil.align(SIZE_OF_INT + channel.length(), SIZE_OF_INT) +
                SIZE_OF_INT + source.length();
            offset += BitUtil.align(recordLength, ENTRY_ALIGNMENT);
        }

        return recordsRead;
    }
@Test
    void shouldReadTwoEntries()
    {
        final long initialBytesLostOne = 32;
        final int timestampMsOne = 7;
        final int sessionIdOne = 3;
        final int streamIdOne = 1;
        final String channelOne = "aeron:udp://stuffOne";
        final String sourceOne = "127.0.0.1:8888";

        final long initialBytesLostTwo = 48;
        final int timestampMsTwo = 17;
        final int sessionIdTwo = 13;
        final int streamIdTwo = 11;
        final String channelTwo = "aeron:udp://stuffTwo";
        final String sourceTwo = "127.0.0.1:9999";

        lossReport.createEntry(initialBytesLostOne, timestampMsOne, sessionIdOne, streamIdOne, channelOne, sourceOne);
        lossReport.createEntry(initialBytesLostTwo, timestampMsTwo, sessionIdTwo, streamIdTwo, channelTwo, sourceTwo);

        assertEquals(2, LossReportReader.read(buffer, entryConsumer));

        final InOrder inOrder = inOrder(entryConsumer);
        inOrder.verify(entryConsumer).accept(
            1L, initialBytesLostOne, timestampMsOne, timestampMsOne, sessionIdOne, streamIdOne, channelOne, sourceOne);
        inOrder.verify(entryConsumer).accept(
            1L, initialBytesLostTwo, timestampMsTwo, timestampMsTwo, sessionIdTwo, streamIdTwo, channelTwo, sourceTwo);

        verifyNoMoreInteractions(entryConsumer);
    }