private static boolean continueConsuming(final int messagesConsumed, final int maxMessages) {
        return maxMessages > 0 && messagesConsumed < maxMessages;
    }
Returns up to `maxMessages` by reading via the provided consumer (the topic(s) to read from
are already configured in the consumer).

@param topic          Kafka topic to read messages from
@param consumer       Kafka consumer
@param waitTime       Maximum wait time in milliseconds
@param maxMessages    Maximum number of messages to read via the consumer
@return The KeyValue elements retrieved via the consumer
streams/src/test/java/org/apache/kafka/streams/integration/utils/IntegrationTestUtils.java