...
Code Block |
---|
/** * Block until we have an assignment (and fetch offsets, etc.). * <p> * It is an error to not have subscribed to any topics or partitions before polling for data. * <p> * Throws a {@link TimeoutExceptionClientTimeoutException} if the {@code maxBlockTime} expires before the operation completes, but it * is safe to try again. * * @param maxBlockTime The maximum time to block and poll for metadata updates * * @throws org.apache.kafka.common.errors.TimeoutExceptionClientTimeoutException if the metadata update doesn't complete within the maxBlockTime * @throws org.apache.kafka.common.errors.WakeupException if {@link #wakeup()} is called concurrently with this function * @throws org.apache.kafka.common.errors.InterruptException if the calling thread is interrupted concurrently with this function * @throws org.apache.kafka.clients.consumer.InvalidOffsetException if the offset for a partition or set of * partitions is undefined or out of range and no offset reset policy has been configured * @throws org.apache.kafka.common.errors.AuthenticationException if authentication fails. See the exception for more details * @throws org.apache.kafka.common.errors.AuthorizationException if caller lacks Read access to any of the subscribed * topics or to the configured groupId. See the exception for more details * @throws org.apache.kafka.common.KafkaException for any other unrecoverable errors (e.g. invalid groupId or * session timeout, or any new error cases in future versions) * @throws java.lang.IllegalArgumentException if the timeout value is negative * @throws java.lang.IllegalStateException if the consumer is not subscribed to any topics or manually assigned any * partitions to consume from */ public void awaitAssignmentMetadata(final Duration maxBlockTime); /** * Fetch data for the topics or partitions specified using one of the subscribe/assign APIs. It is an error to not have * subscribed to any topics or partitions before polling for data. * <p> * On each poll, consumer will try to use the last consumed offset as the starting offset and fetch sequentially. The last * consumed offset can be manually set through {@link #seek(TopicPartition, long)} or automatically set as the last committed * offset for the subscribed list of partitions * * * @param maxBlockTime The maximum time to block and poll for metadata updates or data. * * @return map of topic to records since the last fetch for the subscribed list of topics and partitions * * @throws org.apache.kafka.clients.consumer.InvalidOffsetException if the offset for a partition or set of * partitions is undefined or out of range and no offset reset policy has been configured * @throws org.apache.kafka.common.errors.WakeupException if {@link #wakeup()} is called before or while this * function is called * @throws org.apache.kafka.common.errors.InterruptException if the calling thread is interrupted before or while * this function is called * @throws org.apache.kafka.common.errors.AuthenticationException if authentication fails. See the exception for more details * @throws org.apache.kafka.common.errors.AuthorizationException if caller lacks Read access to any of the subscribed * topics or to the configured groupId. See the exception for more details * @throws org.apache.kafka.common.KafkaException for any other unrecoverable errors (e.g. invalid groupId or * session timeout, errors deserializing key/value pairs, or any new error cases in future versions) * @throws java.lang.IllegalArgumentException if the timeout value is negative * @throws java.lang.IllegalStateException if the consumer is not subscribed to any topics or manually assigned any * partitions to consume from */ public ConsumerRecords<K, V> poll(final Duration maxBlockTime) |
...