/** * Block until a record can be read from this consumer's topic, and return the value in that record. * * @return the value; never null * @throws InterruptedException if the thread is interrupted while blocking */ default V nextValue() throws InterruptedException { return nextRecord().value(); }
/** * Block until a record can be read from this consumer's topic or until the timeout occurs, and if a record was read * return the value in that record. * * @param timeout the maximum amount of time to block to wait for a record * @param unit the unit of time for the {@code timeout} * @return the value, or null if the method timed out * @throws InterruptedException if the thread is interrupted while blocking */ default V nextValue(long timeout, TimeUnit unit) throws InterruptedException { ConsumerRecord<K, V> record = nextRecord(timeout, unit); return record != null ? record.value() : null; }